Description: input a date of the string type, for example, 2012-04-13 or 2012/04/13. If the verification succeeds, true is returned. Otherwise, false is returned.
var isDateFormat = function(_datestr){ var dateStr = _datestr.match(/^(\d{4})-(\d{2})-(\d{2})$/); var intYear; var intMonth; var intDay; var boolLeapYear; if(dateStr != null){ intYear = parseInt(dateStr[0],10); intMonth = parseInt(dateStr[2],10); intDay = parseInt(dateStr[3],10); if(dateStr.length == 4){ if(!(intMonth > 12) && !(intMonth < 1)){ if(intMonth==1||intMonth==3||intMonth==5||intMonth==7||intMonth==8||intMonth==10||intMonth==12){ if(intDay>=1&&intDay<=31){ return true; } else { return false; } } else { if(intMonth==4||intMonth==6||intMonth==9||intMonth==11){ if(intDay>=1 && intDay<=30){ return true; } else { return false; } } else { if(intMonth==2){ if(intDay < 1){ return false; } else { var boolLeapYear = false; if(intYear%4 == 0 && intYear%100 != 0){ boolLeapYear = true; } if(boolLeapYear){ if(intDay > 29){ return false; } else { return true; } } else { if(intDay > 28){ return false; } else { return true; } } } } } } } }else { returnfalse; } } else { returnfalse; }};