Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable setting of focus for jQuery UI datepicker

Tags:

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...

like image 301
black666 Avatar asked Aug 02 '11 12:08

black666


People also ask

How do I disable UI Datepicker trigger?

Datepicker has a built-in disable method for this you can use, which also disables the text input, like this: $("#datepicker"). datepicker("disable");

How do I restrict Datepicker?

You can restrict the users from selecting a date within the particular range by specifying MinDate and MaxDate properties. The default value of MinDate property is 1/1/1920 and MaxDate property is 12/31/2120 .

How do I stop Datepicker pop up?

$(document). mouseup(function (e) { $('#example1'). Close(); });


1 Answers

set input to ReadOnly

<input type="text" id="datePicker" readonly> 
like image 95
Michal Shulman Avatar answered Oct 17 '22 05:10

Michal Shulman