curiouswebster
asked on
Setting the focus with jQuery UI Date Picker
I have the validation almost working and need to return the focus to the date control, after the user clicks OK on the error messagebox.. When the user types an invalid date into the text field I display an error message saying "You have entered an invalid date". This works okay. But after clicking the OK button, I'd like to put focus back onto that control with the faulty date.
How can I do this?
Thanks!
How can I do this?
Thanks!
ASKER
The focus does not return but I do see FireBug open up on the call to debugger. Cool.
remove << debugger; >>, line two, it should work
ASKER
I took that out but it stilll does not work. We have some third party library (I think) that turns the currently selected field yellow. I think that's getting the focus and not giving it to the field properly.
try : setTimeout(function() { $("#datepicker").focus(); }, 250);
instead : $(this).focus();
instead : $(this).focus();
ASKER
Where do I locate that function?
ASKER
It does not work.
I located it here:
$(function () {
$("#datepicker").datepicke r({
// code removed for brevity
});
setTimeout(function () {
$("#datepicker").focus();
}, 250);
});
I located it here:
$(function () {
$("#datepicker").datepicke
// code removed for brevity
});
setTimeout(function () {
$("#datepicker").focus();
}, 250);
});
>Where do I locate that function?
inside onClose, check my first post
inside onClose, check my first post
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, that worked!
debugger;
if (dateText != $.datepicker.formatDate($.
{
alert("The date you specified is not a valid date.");
this.value = '';
$(this).focus();
}