Return to Snippet

Revision: 15319
at June 30, 2009 15:07 by mardix


Initial Code
/**
 * 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;
}

Initial URL

                                

Initial Description
A simple JS script to validate a date. It returns a boolean type (true | false)

Initial Title
isDateValid  - Validate a date in javascript

Initial Tags
date

Initial Language
JavaScript