当前位置: 代码网 > it编程>编程语言>其他编程 > 如何验证日期输入是否正确?

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

2024年05月18日 其他编程 我要评论
<%option explicitdim strdate ' 记录输入的日期,字符型.dim datdate ' 测试输入的日期是否正确,日期型.<html>%&

<%
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]

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com