答案:function isdate(strDate){<br>
var strSeparator = "-"; //日期分隔符<br>
var strDateArray;<br>
var intYear;<br>
var intMonth;<br>
var intDay;<br>
var boolLeapYear;<br>
<br>
strDateArray = strDate.split(strSeparator);<br>
<br>
if(strDateArray.length!=3) return false;<br>
<br>
intYear = parseInt(strDateArray[0],10);<br>
intMonth = parseInt(strDateArray[1],10);<br>
intDay = parseInt(strDateArray[2],10);<br>
<br>
if(isNaN(intYear)||isNaN(intMonth)||isNaN(intDay)) return false;<br>
<br>
if(intMonth>12||intMonth<1) return false;<br>
<br>
if((intMonth==1||intMonth==3||intMonth==5||intMonth==7||intMonth==8||intMonth==10||intMonth==12)&&(intDay>31||intDay<1)) return false;<br>
<br>
if((intMonth==4||intMonth==6||intMonth==9||intMonth==11)&&(intDay>30||intDay<1)) return false;<br>
<br>
if(intMonth==2){<br>
if(intDay<1) return false;<br>
<br>
boolLeapYear = false;<br>
if((intYear%100)==0){<br>
if((intYear%400)==0) boolLeapYear = true;<br>
}<br>
else{<br>
if((intYear%4)==0) boolLeapYear = true;<br>
}<br>
<br>
if(boolLeapYear){<br>
if(intDay>29) return false;<br>
}<br>
else{<br>
if(intDay>28) return false;<br>
}<br>
}<br>
<br>
return true;<br>
}<br>
上一个:javascript里类似select case 该如何用?
下一个:js中with的和case的用法