Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2006, 03:20 AM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Isdate validation problem

Hi,

I am maintaining an old asp site that we developed a few years ago and we have just noticed a problem with some of the error checking. We have a form that has about 12 different text fields where the user enters dates. When the form is submitted these are checked using the isdate function in an asp form and this picks up any obvious errors. We are based in the UK and we have found that users can enter 31/01/2006 fine but also 01/31/2006 (U.S. format) that we do not want to be accepted. I have had a look around and found that this is a fault of isdate and that it recognises both dates as correct which we do not want. Does anybody have any date checking code that we can use that will only accept U.K dates? Note that we need to do the error checking in asp and do not want to use javascript.

Thanks

John



 
Old April 19th, 2006, 06:25 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;where the user enters dates.
I choose to use a date picker. this way they can not enter dates incorrectly

;;isdate function in an asp form and this picks up any obvious errors
IMO They are not errors. End user are entering the wronf format probably because your form is clearly poorley validated.

;;I have had a look around and found that this is a fault of isdate
There is no fault in the isDate function, we all use it.

;;both dates as correct
Yes both formats are correct, so is yyyy/../...

;;;Does anybody have any date checking code that we can use that will only accept U.K dates?

you can use the following function to get dd/mm/yyyy (it is called audate because it gives me an Australian date:
FUNCTION auDate(varDate)
   IF isNull(varDate) OR Trim(varDate) = "" OR varDate = "Null" THEN
      auDate = "Null"
   ELSE
      auDate = "" & day(DateValue(varDate)) & "/" & month(DateValue(varDate)) & "/" & Year(DateValue(varDate)) & " " & TimeValue(varDate) & ""
   END IF
END FUNCTION

Use it like so (dont forget to trim all your values, a good practice):
auDate(trim(request.form("yourDateFieldname")))

The above function is very easy to tweak into what ever date format you would like





Wind is your friend
Matt




Similar Threads
Thread Thread Starter Forum Replies Last Post
validation problem Ashleek007 JSP Basics 1 June 18th, 2007 01:16 AM
Validation problem monika.vasvani ASP.NET 1.0 and 1.1 Professional 1 November 25th, 2006 01:44 PM
Email validation problem mattastic Javascript How-To 1 May 19th, 2005 01:10 AM
validation problem Abhinav_jain_mca General .NET 6 August 5th, 2004 02:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.