JS判断日期

来源:互联网 发布:江恩轮中轮软件 编辑:程序博客网 时间:2024/04/28 20:05
<script type="text/javascript">  function checkdate()  {      var s1 = document.form1.date1.value;   var s2 = document.form1.date2.value;         if(s1 != "" && s2 != "") {    s1 = s1.replace(/-/g, "/");     s2 = s2.replace(/-/g, "/");          s1 = new Date(s1);    s2 = new Date(s2);    var days= parseInt(s1.getTime() - s2.getTime());     if(days > 0) {     alert("开始时间比结束大,请重新输入!");     return false;    }   } else {    alert("请输入查询日期");    return false;   }  } </script>