/ Published in: JavaScript
                    
                                        
A simple JS script to validate a date. It returns a boolean type (true | false)
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/**
* Check if a date is valid
* @return bool
* @author Mardix
* @since: June 30 2009
*/
isDateValid = function(year,month,date){
if(year && month && date){
if(month==2){
if((year%4 == 0) && date>29)
return false
else if((year%4!=0) && date > 28)
return false;
}
if((month!=2 && month!=8) && ((month%2 != 1) && date>30))
return false;
else
return true;
}
else
return false;
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                