<script language="JavaScript">
function check_confirm(form){
var cks = queryForm1.elements;
if (datecompare(cks[3].value,cks[5].value)==false) {
alert("结束时间 应该在 开始时间 之后");
return;
}
check(form);
}
//功能介绍:检查第一个日期是否小于第二个日期
//参数说明:要检查的字符串(YYYY-MM-DD)
//返回值:false:不是 true:是
function datecompare(strDate1, strDate2){
var nYear2, nMonth2, nDay2;
nYear1 = strDate1.substr(0,4);
nMonth1 = strDate1.substr(5,2);
nDay1 = strDate1.substr(8,2);
nYear2 = strDate2.substr(0,4);
nMonth2 = strDate2.substr(5,2);
nDay2 = strDate2.substr(8,2);
if ( nYear1 > nYear2 ) {
return false;
}
if ( nYear1 == nYear2 ) {
if (nMonth1 == nMonth2) {
if ( nDay1 > nDay2 )
return false;
}
if (nMonth1>nMonth2) {
return false;
}
}
return true;
}
</script>
----------------------------------调用方法------------------------------------------------
<input type="button"
value="查询" οnclick="javascript:check_confirm(document.queryForm1);" class="button_w">