当前位置: 移动技术网 > IT编程>开发语言>其他编程 > 如何验证日期输入是否正确?

如何验证日期输入是否正确?

2017年12月08日  | 移动技术网IT编程  | 我要评论

<%
option explicit
dim strdate           

' 记录输入的日期,字符型.
dim datdate           

' 测试输入的日期是否正确,日期型.

<html>
%>
<head>
<title>
千花飞舞之日期验证</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../css/export.css" type="text/css">
</head>

<body text="#000000">

<form name="inputdate" action="<% = request.servervariables("script_name") %>" method="post">
<table width="500" border="1" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td background="../pic/br.jpg">
      <table width="500" border="0" cellpadding="4" cellspacing="4" class="9p">
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2" height="60">
            <div align="center">
请输入所要查询的日期:
              <input type="text" name="strdate" value="<% = cstr(year(now())) & "-" & cstr(month(now()))
& "-" & cstr(day(now()))%>" size="10" maxlength="10">
            </div>
          </td>
        </tr>
        <tr>
          <td width="50%">
            <div align="center">
              <input type="submit" name="submit" value="
确认">
            </div>
          </td>
          <td>
            <div align="center">
              <input type="reset" name="submit2" value="
取消">
            </div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>
<%
strdate = request.form("strdate")
if strdate <> "" then
    on error resume next
    datdate = cdate(strdate)
    if err.number = 0 then
%>
<script language="javascript">
<!--
    inputdate.action="typealert.asp"
    inputdate.submit()
//-->
</script>
<%
    else
%>
<script language="javascript">
<!--
    alert ("
,您输入的日期错啦,请重新输入!")
//-->
</script>
<%
    end if
end if
%>
</body></html>

 

[1]

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网