PDA

View Full Version : JavaScript - Date Validation



balusamy
11-26-2008, 03:10 PM
I have 3 date fields in a form (month, day, year). The 'month' field is a drop down menu as well as the 'day' field and 'year' field.

The respective field id's are the same names.

Basically, I need to add some JavaScript that would prevent a user from submitting the form if he or she inputted a date in the above fields that was within 31 days of the current day. Anything outside of 31 days is okay. I don't want the error message to be returned upon entering the date, I need it to be returned when they try to use the submit button, because I'm using in page error messaging.

How can I tell these 3 fields to verify the current date against the entered date, and if it's 31 days or less, send back an in page error message, if it's over 31 days than the form would submit.

Balu