<html>
<script>
function dateValid(){
var beginDate = new Date(document.getElementById("sStartSaveDate").value.replace(/-/g,"/"));
var endDate = new Date(document.getElementById("sEndSaveDate").value.replace(/-/g,"/"));
if(beginDate >= endDate){
alert("结束时间必须大于开始时间!");
return false;
}else{alert("ok!");}
}
</script>
<body>
开始时间:<input type="text" id="sStartSaveDate">
结束时间:<input type="text" id="sEndSaveDate">
<input type="button" οnclick="javascript:dateValid();return;" value="验证">
</body>
</html>
<script>
function dateValid(){
var beginDate = new Date(document.getElementById("sStartSaveDate").value.replace(/-/g,"/"));
var endDate = new Date(document.getElementById("sEndSaveDate").value.replace(/-/g,"/"));
if(beginDate >= endDate){
alert("结束时间必须大于开始时间!");
return false;
}else{alert("ok!");}
}
</script>
<body>
开始时间:<input type="text" id="sStartSaveDate">
结束时间:<input type="text" id="sEndSaveDate">
<input type="button" οnclick="javascript:dateValid();return;" value="验证">
</body>
</html>