curiouswebster
asked on
Using the date picker for client side date validation
My website currently has 3 drop down for date: a Month, a Day and a Year drop downs. It's looking like to simply add client side validation wil be easiest if I use the jQuery UI Date Picker as a background validator.
I need to check date like 2/30/2000 and tell the user it's an invalid date. I have the folowing validation code that's working:
onClose: function (dateText, inst) {
if (dateText != $.datepicker.formatDate($. datepicker .regional[ ''].dateFo rmat, new Date(dateText))) {
alert("The date you specified is not a valid date.");
setTimeout(function () { $("DOB").focus(); }, 250);
}
}
How can I use this as a background validation test? I'd need to re-write it as a stand-alone JavaScript function, right?
How would I make the click event for the button succeed when the date is valid, yet fail and abort the submission when it's a bad date?
Please explain how I'd show the error message.
Thanks!
I need to check date like 2/30/2000 and tell the user it's an invalid date. I have the folowing validation code that's working:
onClose: function (dateText, inst) {
if (dateText != $.datepicker.formatDate($.
alert("The date you specified is not a valid date.");
setTimeout(function () { $("DOB").focus(); }, 250);
}
}
How can I use this as a background validation test? I'd need to re-write it as a stand-alone JavaScript function, right?
How would I make the click event for the button succeed when the date is valid, yet fail and abort the submission when it's a bad date?
Please explain how I'd show the error message.
Thanks!
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER