Categories




Check A Date Is Valid

This example displays a form on a page . The user then enters a date , if the date is invalid then a message will be displayed on the screen . Examples of valid dates are as follows

12-12-09

12/12/09
<form method =”post” action=”<%= Request.ServerVariables(“SCRIPT_NAME”) %>”>
<input type =”text” name=”date”><br>
<input type=”submit”>
</form>
<%

Dim strDate , blnValid , dteDate
If Request.ServerVariables(“CONTENT_LENGTH”) <>0 Then
strDate = Trim(Request.Form(“date”))
‘check and see if the user entry is a date
If isDate(strDate) Then
dteDate = CDate(strDate)
’set variable to true
blnValid = True
Else
‘display invalid date message
Response.Write “You entered an invalid date”
End If
‘displayvalid date message
If blnValid = True Then
Response.Write “The date you entered was ” & dteDate
End If
End If
%>

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>