Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ipad web application: How do I prevent the keyboard from popping up on jquery datepicker

I have a form with an date field with a jquery datepicker attached to it.

When I select the date field the datepicker pops up but then the iPad keyboard slides into view and obscures the datepicker.

How do I prevent the keyboard from popping up in this situation?

like image 751
Rob Osborne Avatar asked Aug 21 '10 22:08

Rob Osborne


People also ask

How do I stop datepicker pop up?

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

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?

If you like to restrict access of users to select a date within a range then there is minDate and maxDate options are available in jQuery UI. Using this you can set the date range of the Datepicker. After defining these options the other days will be disabled which are not in a defined range.

How do I maxDate datepicker?

Try this: $("#datepicker"). datepicker({ minDate: -0, maxDate: new Date(2013, 1, 18) }); If you want use hard coded date, use the new Date(2013, 1, 18) pattern.


2 Answers

I used a slightly modified version of Rob Osborne's solution and it successfully prevented the keyboard from popping up on the iPad and iPhone.

$(".datePicker").datepicker({     showOn: 'button',     onClose: function(dateText, inst)      {          $(this).attr("disabled", false);     },     beforeShow: function(input, inst)      {         $(this).attr("disabled", true);     } }); 
like image 66
cdeutsch Avatar answered Sep 21 '22 19:09

cdeutsch


Instead of disabling the input give it a "readonly" property. This is better then disabling it because you can save the form without changing it.

Here is more info about readonly.

like image 29
Miriam Salzer Avatar answered Sep 21 '22 19:09

Miriam Salzer