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

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.


That's how I managed to deal with this problem by making the browser think the user blured the input so it hides the keyboard before it has time to show :

$('blabla')
    .datepicker(
    {
        /* options */
    })
    .on('focus',function()
    {
        $(this).trigger('blur');
    });

Works well for me where many of the other solutions I found didn't !