function checkDate() {
var strDate = document.myform.txtTime.value;
if (strDate != "") {
var reg = /^\d{4}-(0[1-9]|1[0-2])-(0[0-9]|1[0-9]|2[0-9]|3[0-1])$/;
if (reg.test(strDate)) {
strayy = strDate.split("-");
if (strayy[1] == 2) {
if (strayy[0] % 4 == 0) {
if (strayy[2] > 29) {
alert("闰年2月只有29天,请重新输入。");
return false;
}
else {
return true;
}
}
else {
if (strayy[2] > 28) {
alert("平年2月只有28天,请重新输入。");
return false;
}
else {
return true;
}
}
}
else {
if (strayy[1] == 4 || strayy[1] == 6 || strayy[1] == 9 || strayy[1] == 11) {
if (strayy[2] > 30) {
alert(strayy[1] + "月只有30天,请重新输入。");
return false;
}
else {
return true;
}
}
}
}
else {
alert("输入日期格式不正确\n请重新输入!");
document.myform.txtTime.focus();
return false;
}
}
else {
alert("输入不能为空!");
document.myform.txtTime.focus();
return false;
}
}