prevent iphone default keyboard when focusing an <input> prevent iphone default keyboard when focusing an <input> jquery jquery

prevent iphone default keyboard when focusing an <input>


By adding the attribute readonly (or readonly="readonly") to the input field you should prevent anyone typing anything in it, but still be able to launch a click event on it.

This is also usefull in non-mobile devices as you use a date/time picker


You can add a callback function to your DatePicker to tell it to blur the input field before showing the DatePicker.

$('.selector').datepicker({   beforeShow: function(){$('input').blur();}});

Note: The iOS keyboard will appear for a fraction of a second and then hide.


inputmode attribute

<input inputmode='none'>

The inputmode global attribute is an enumerated attribute that hints at the type of data that might be entered by the user while editing the element or its contents. It can have the following values:

none -No virtual keyboard. For when the page implements its own keyboard input control.


I am using this successfully (Tested on Chrome/Android)

CSS-Tricks: Everything You Ever Wanted to Know About inputmode