<html>
<head>
<script type="text/javascript">
function checkDate(){
var str=document.getElementById('txt').value;
var arr=str.split('-');
var myDate=new Date();
var today=new Date();
myDate.setFullYear(arr[0],arr[1]-1,arr[2]);
if(myDate>today){alert(">");}
else{alert("<=");}
}
</script>
</HEAD>
<body>
<input type="text" id="txt"/>
<input type="button" id="btn" value="判断" οnclick="checkDate()"/>
</body>
</html>
通过JavaScript判断输入日期是否在今天之前
最新推荐文章于 2023-03-22 10:30:21 发布