Jquery – Disable setting of focus for jQuery UI datepicker

jqueryjquery-mobilejquery-ui-datepickermobile

There is an option with the jQuery UI datepicker to only open the datepicker when a button image is clicked. See the following for an example:

http://jqueryui.com/demos/datepicker/#icon-trigger

The problem is that the focus is in the textfield as soon as the datepicker opens. Is it possible to disable the setting of the focus?

When using a page like the above on a mobile device like an iPhone, the keyboard pops up because the textfield gains the focus. This is not really userfriendly since you have to close the keyboard to actually get to the datepicker and use it…

Best Answer

set input to ReadOnly

<input type="text" id="datePicker" readonly>