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?
$(document). mouseup(function (e) { $('#example1'). Close(); });
Datepicker has a built-in disable method for this you can use, which also disables the text input, like this: $("#datepicker"). datepicker("disable");
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.
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.
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); } });
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With