用JAVASCRIPT判断日期的先后(计算日期差)
在网页制作过程中,有时会碰到判断日期的先后.如在表单中输入开始日期,结束日期.一般讲结束日期应该在开始日期后面.下面我给出一段代码来实现

源码:
<html>
<head>
<title>are you ready</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
<!--
function check()
 {
  iy = document.form.in_year.value;
  im = document.form.in_month.value;
  id = document.form.in_date.value;
  oy = document.form.out_year.value
  om = document.form.out_month.value;
  od = document.form.out_date.value;
 
  var check_out=new Date(oy,om-1,od);
  var check_in=new Date(iy,im-1,id);
  var days_diff=(check_out.valueOf()-check_in.valueOf())/86400000;
 
 if(days_diff<0)
  alert("请输入正确的结束时间");
  }
//-->
</script>


</head>

<body bgcolor="#FFFFFF">
<form name="form" onsubmit=" return check()">
 <p>开始时间:
  <input type="text" name="in_year" size="15">
  年
  <input type="text" name="in_month" size="15">
  月
<input type="text" name="in_date" size="15">
  日 </p>
 <p> 结束时间:
  <input type="text" name="out_year" size="15">
  年
  <input type="text" name="out_month" size="15">
  月
  <input type="text" name="out_date" size="15">
  日
  <input type="submit" name="submit" value="提交">
 </p>
</form>
</body>
</html>