function checkform()
{
str1=Trim(contractSearch.beginDate.value);
str2=Trim(contractSearch.endDate.value);
start=new Date(str1.replace("-",",")).getTime();
end=new Date(str2.replace("-",",")).getTime();
if(start>end){
alert("开始日期不能大于终止日期!");
contractSearch.beginDate.focus();
return false;
}
return true;
}
{
str1=Trim(contractSearch.beginDate.value);
str2=Trim(contractSearch.endDate.value);
start=new Date(str1.replace("-",",")).getTime();
end=new Date(str2.replace("-",",")).getTime();
if(start>end){
alert("开始日期不能大于终止日期!");
contractSearch.beginDate.focus();
return false;
}
return true;
}
最原始的方法
全部转换成毫秒比较其实还有一个投机取巧的方法(推荐)
如2001/01/01 和 2000/12/11 比较
可把"2001/01/01" --> 20010101,"2000/12/11" --> 20001211
显然20010101 > 20001211 所以 2001/01/01在2000/12/11之后!