网络编程 
首页 > 网络编程 > 浏览文章

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

(编辑:jimmy 日期: 2024/5/9 浏览:3 次 )

<%
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="">
<!--
    InputDate.action="TypeAlert.asp"
    InputDate.submit()
//-->
</Script>
<%
    Else
%>
<Script Language="">
<!--
    alert ("噢,您输入的日期错啦,请重新输入!")
//-->
</Script>
<%
    End If
End If
%>
</body></html>

 

[1]

上一篇:如何制作一个倒计时的程序?
下一篇:如何计算出当前日期属于定义时间段内的第几星期?
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网