Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

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[''].dateFormat, 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!
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of curiouswebster

ASKER

Thanks!