校验日期格式2008-01-01
function IsValidDate(dateStr){
var datePat=/^(\d{4})(\-)(\d{1,2})(\-)(\d{1,2})$/;
var matchArray = dateStr.match(datePat);
if (matchArray==null) {
return false;
}
year=matchArray[1];
month=matchArray[3];
day=matchArray[5];
if (year.length!=4 || month.length!=2 || day.length!=2)
{
return false;
}
if (month < 1 || month > 12)
{
return false;
}
if (day < 1 || day > 31)
{
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31)
{
return false;
}
if (month==2)
{
var isleap=(year % 4==0 && (year % 100 !=0 || year % 400==0));
if (day>29 || ((day==29) && (!isleap)))
{
return false;
}
}
return true;
}