function check()
{
var dates=document.form2.YYYY.value+"-"+document.form2.MM.value+"-"+document.form2.DD.value
if (isInvalidDate(dates,"-"))
{
alert("您的日期添写错误!");
return false;
}
return true;
}
function isInvalidDate(theDate,separator){
default_style=1
if (theDate.length>10 || theDate.length<8)
return true
idx1=theDate.indexOf(separator)
if (idx1==-1)
return true
idx2=theDate.indexOf(separator,idx1+1)
if (idx2==-1)
return true
if (isInvalidDate.arguments.length>2)
default_style=isInvalidDate.arguments[2]
if (default_style<1 || default_style>9){
alert("日期填写有误")
return true
}
if (default_style==1){
theYear=theDate.substring(0,idx1)
theMonth=theDate.substring(idx1+1,idx2)
theDay=theDate.substring(idx2+1)
}
if (default_style==2){
theMonth=theDate.substring(0,idx1)
theDay=theDate.substring(idx1+1,idx2)
theYear=theDate.substring(idx2+1)
}
if (theDay.length>2)
return true
if (parseYMD(theYear,theMonth,theDay)>0)
return true
else
return false
}