March 23, 2012

Unable to remove Autofocus in ui-dialog

Question by Josh

The first element in my jQuery UI Dialog is an input, which when selected opens a datepicker…

How can I disable this input from being selected first?

Answer by Starx

Very simple, just trigger the blur event on the input elements when the dialog box opens.

$("#dialog").dialog({
    open: function(event, ui) {
        $("input").blur();
    }
});

Check it out here

Solution with datepicker

NOTE: For more in-depth solution to this problem, read this answer too.

...

Please fill the form - I will response as fast as I can!