User entered date value validation in ASP

We can collect date values from user and check the inputs for a valid date or not by using IsDate () function. Here we will give the options to the user to select month, date and year from list boxes and text box and then create a date variable using it. Then we will check the date variable and find out it is a valid date or not.

We will display a message accordingly saying correct date or not.

Here is the code below to check the user entered date value.

<%@ Language=VBScript %>
<% Option Explicit %>

<title>(Type a title for your page here)</title>


Dim todo
if todo="submit" then
Dim month, dt, year, my_date
my_date=year + "/" + month + "/" + dt
if(IsDate(my_date)) then
Response.Write month + "/" + dt + "/" + year & " is a valid date "
Response.Write month + "/" + dt + "/" + year & " is a Not a valid date "

End If
End If
<form method=post name=f1 action=''><input type=hidden name=todo value=submit>
<table border="0" cellspacing="0" >
<tr><td align=left >

<select name=month value=''>Select Month</option>
<option value='01'>January</option>
<option value='02'>February</option>
<option value='03'>March</option>
<option value='04'>April</option>
<option value='05'>May</option>
<option value='06'>June</option>
<option value='07'>July</option>
<option value='08'>August</option>
<option value='09'>September</option>
<option value='10'>October</option>
<option value='11'>November</option>
<option value='12'>December</option>

</td><td align=left >
Date<select name=dt >
<option value='01'>01</option>
<option value='02'>02</option>
<option value='03'>03</option>
<option value='04'>04</option>
<option value='05'>05</option>
<option value='06'>06</option>
<option value='07'>07</option>
<option value='08'>08</option>
<option value='09'>09</option>
<option value='10'>10</option>
<option value='11'>11</option>
<option value='12'>12</option>
<option value='13'>13</option>
<option value='14'>14</option>
<option value='15'>15</option>
<option value='16'>16</option>
<option value='17'>17</option>
<option value='18'>18</option>
<option value='19'>19</option>
<option value='20'>20</option>
<option value='21'>21</option>
<option value='22'>22</option>
<option value='23'>23</option>
<option value='24'>24</option>
<option value='25'>25</option>
<option value='26'>26</option>
<option value='27'>27</option>
<option value='28'>28</option>
<option value='29'>29</option>
<option value='30'>30</option>
<option value='31'>31</option>

</td><td align=left >
Year(yyyy)<input type=text name=year size=4 value=2006>
<input type=submit value=Submit>


Check for same tutorial on PHP for validating date using checkdate function

We can use regular expression to check user data validation

Be the first to post comment on this article :


Post Comment This is for short comments only. Use the forum for more discussions.

HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2015 All rights reserved worldwide Privacy Policy Disclaimer