Use on Error Resume next to validate the date input (ASP 3.0)

Source: Internet
Author: User
Tags date
The error has just been asked to use JavaScript to verify the date, recall that they wrote a bunch of functions to verify the date, and did not involve a leap year problem, recently saw ASP 3.0 about on the Error Resume next usage, brainwave, hehe ... It's so cool!
<%
Option Explicit
Dim strdate ' records the date entered, character type
Dim datdate ' test input date is correct, date type %>
<title> Date Selection </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<link rel= "stylesheet" href= ". /css/export.css "type=" Text/css ">

<body bgcolor= "#FFFFFF" text= "#000000" >

<form name= "Inputdate" action= <% = Request.ServerVariables ("Script_name")%> "method=" POST >
<table width= "border=" 1 "cellpadding=" 0 "cellspacing=" 0 "align=" center ">
<tr>
<td background= ". /pic/br.jpg ">
<table width= "border=" 0 "cellpadding=" 4 "cellspacing=" 4 "class=" 9p ">
<tr>
&LT;TD colspan= "2" > </td>
</tr>
<tr>
&LT;TD colspan= "2" height= ">"
<div align= "center" > Please enter the date you want to query:
<input type= "text" name= "strdate" value= "<% = CStr (year (today)) &"-"& CStr (Month (now)) &"-"& C STR (day ())%> "size=" maxlength= "ten" >
</div>
</td>
</tr>
<tr>
&LT;TD width= "50%" >
<div align= "center" >
<input type= "Submit" name= "Submit" value= "Confirmation" >
</div>
</td>
<td>
<div align= "center" >
<input type= "reset" name= "Submit2" value= "Cancel" >
</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 ("You entered the wrong date, please re-enter!") ")
-->
</Script>
<%
End If
End If
%>
</body>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.