In your asp page
you can check it as
<%
If IsDate(Request.Form("txtSt
Response.Redirect("Invali Date")
End If
%>
Main Topics
Browse All TopicsHi
I have a form which only accepts date type dd/mm/yyyy, when the user enters a incorrect format eg 12/11/04 (instead of 12/11/2004) a page cannot be displayed appears. I am looking for code which will vill give the user a error message when they submit a incorrect format
I have something ike this so far:
<%
If (Request.Form("txtStartDat
Response.Redirect("Reports
'End If
%>
PLEASE HELP THIS IS URGENT
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
why dont you just create a drop down list on the webpage that ensures that the format is correct
ie:
<select name="DAY">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
etc...
</select>
<select name="MONTH">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
etc...
</select>
<select name="YEAR">
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
etc...
</select>
Then when the form/webpage is sent you add the dates together to get the dd/mm/yyyy format
dFullDate = Day & "/" & Month & "/" Year
I would recommend highly using isDate(). While dropdowns are okay, I wouldn't recommend them. You still don't get away from doing validation on them, because you still have to worry about users entering 04/31/2003, 02/30/2003, 09/31/2002, and many other invalid date combinations. By far, the easiest way to validate your dates is to simply use the vbscript function "isDate()", as nurbek has already suggested.
Also, you say that you get "Page cannot be displayed error" when a bad date is submitted, right? Well, please do this:
-- In internet explorer, go to tools --> internet options
-- select the "advanced" tab all the way to the right
-- under the "browsing" section, find the item that says "Show friendly HTTP error messages"
-- please make sure this value is UNCHECKED. Leaving it checked (ie's default setting) gives you "Page Cannot be displayed" errors, while unchecking it gives you specific, useful ASP errors.
Hope this helps!
peh803
if you asked for javascript
you can call isDate function to validate the dates
function ValidateForm(){
var dt=document.frmSample.txtD
var dt2=document.frmSample.txt
if (isDate(dt.value)==false){
dt.focus()
return false
}
if (isDate(dt2.value)==false)
dt2.focus()
return false
}
return true
}
if you asked for asp
If IsDate(Request.Form("txtSt
' .. invalid date
End If
If IsDate(Request.Form("txtSt
' .. invalid date
End If
Business Accounts
Answer for Membership
by: nurbekPosted on 2004-11-11 at 05:16:54ID: 12554314
you can check it using javascript
DHTML/date _validatio n.asp
before the user submits the page
http://www.smartwebby.com/