10

I am using a monthpicker input (similar to jQuery UI datepicker) for a credit card expiration field.

I need to suppress the iPhone keypad because it hides the month picker.

I have tried setting the field to readonly and it is not an acceptable solution - in Safari iOS 5.1 readonly fields are skipped over in keyboard navigation (prev/next buttons on the keypad). Blurring the field is also not acceptable because it triggers validation (we are also using jQuery validation).

Is there a way to turn off the iPhone keyboard on a single field without setting it readonly or blurring it?

4

2 回答 2

5

I haven't come across the way to hide keyboard. But have you thought alternate way of displaying "input". One option would be using <input type="month" /> which brings the native month picker in iOS5.

Second option would be styling eg. span element as input element (-webkit-appearance not working on iOS), and adding tabindex for the element. This could also work, although I'm not aware of the month picker you're using.

Third option - can't you prevent the validation process when blurring the field is triggered manually?

于 2012-03-22T10:30:36.970 回答
2

我在 Drupal 中遇到了同样的问题,输入字段将动态附加,所以我添加了一些 js,检查 Iphone/Ipad 并添加了“只读”属性

var checkUserAgent = navigator.userAgent;
    if (checkUserAgent.match(/iPad/i) || checkUserAgent.match(/iPhone/i)) {
        var checkBabyId1 = $('#babys_due_date_id').length > 0;
        if (checkBabyId1 == true) {
            $('#babys_due_date_id').find('input').prop('readonly', true);
        }
    }
于 2015-05-26T06:53:14.013 回答