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

Rob Osborne picture Rob Osborne · Aug 22, 2010 · Viewed 37.9k times · Source

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?

Answer

cdeutsch picture cdeutsch · Nov 19, 2010

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);
    }
});