<body>
<script>
function checkdate() {
var datetype = /^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2} [0-2][0-4]:[0-5][0-9]:[0-5][0-9]$/;
var datetype1 = /^[0-9]{4}\/[0-9]{1,2}\/[0-9]{1,2}$/;
if (!(datetype.exec(document.form1.inputdate.value) || datetype1
.exec(document.form1.inputdate.value))) {
alert("sorry:2005-5-5 00:00:00or2005/1/1");
form1.inputdate.focus();
return false;
}
return true;
}
</script>
<form action="" name="form1">
输入日期:<input type="text" name="inputdate"> <input type="button"
onClick="return checkdate();">
</form>
</body>
posted on 2017-11-15 15:58  FAIRY_TALE  阅读(1786)  评论(0编辑  收藏  举报