js 日期比较大小(但有改动)

写道
<html>
<head>
<title>ttttttttttt</title>
<script language="javascript">
function check()
{
try
{
var strdt1=document.getElementById("dt1").value.replace(/- /g,"/");
var strdt2=document.getElementById("dt2").value.replace(/- /g,"/");
var dt1=new Date(Date.parse(strdt1));
var dt2=new Date(Date.parse(strdt2));
alert(dt1>dt2);
}
catch(e)
{
alert("格式错误"+e);
}
}
</script>
</head>
<body>
<form onSubmit="return check();">
<input name="dt1" id="dt1" value="2007-9-9" />
<input name="dt2" id="dt2" value="2007-10-10"/>
<input type="submit" value="提交" />
</form>
</body>
</html>

 

你可能感兴趣的:(JavaScript,html)