PDA

View Full Version : date validation


atulbansal
05-27-2004, 02:52 AM
hi i m pick up the date from the date picker but my problum is i can't able to validate the date popup like in the case of date of birth user can not enter the date which is grater then today but i don't have any script to validate the user so is there may be any kind of script pls help me

agent002
05-27-2004, 06:32 AM
Something like this would do:
var now = new Date();
if(entered_year > now.getFullYear() ||
(entered_year == now.getFullYear() && entered_month > (now.getMonth()+1)) ||
(entered_year == now.getFullYear() && entered_month == (now.getMonth()+1) && entered_day > now.getDate())){
// invalid
}
However, the script you are submitting the info to should also check the date, in case the user didn't have JavaScript enabled or changed the computer's date from the OS's control panel.