I currently have a dialog box with two inputs as its content (with the two inputs using .datepicker()
). When I open dialog box, the first input becomes the focus and the first datepicker automatically appears. I have tried hiding the div and blurring the input, but that causes the datepicker to no longer appear on focus.
Ideally, I want to be able to the following:
Here is my current code:
JAVASCRIPT:
$("#to").datepicker({
onClose: function (selectedDate) {
$("#from").datepicker("option", "minDate", selectedDate);
}
});
$("#from").datepicker({
onClose: function (selectedDate) {
$("#to").datepicker("option", "maxDate", selectedDate);
}
});
$("#settingsDialog").dialog({
autoOpen: false,
open: function (event, ui) {
if ($(".ui-datepicker").is(":visible"))
$(".ui-datepicker").hide();
$("#to").blur();
$this.focus().click();
},
close: function () {
$(this).dialog("close");
}
});
I have also made a jsfiddle demo: http://jsfiddle.net/ARnee/19/
I have searched online for a solution, and found similar questions, but none that seem to help. Could anyone assist me?!
EDIT:
The browser I am using is Chrome.
Try setting the tabindex attribute on the inputs containing the datepicker to -1.
<input type="text" id="to" tabindex="-1" />
EDIT:
<input id="to" type="text" tabindex="-1" />
<input id="from" type="text" tabindex="-1" />
DEMO: http://jsfiddle.net/ARnee/32/
Can stick a dummy input in dialog that has no height so won't be seen. Place it before the datepicker fields
<input style="height:0px; border:none"/>
DEMO: http://jsfiddle.net/ARnee/20/
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