|
Subject:
|
Isdate validation problem
|
|
Posted By:
|
johnckeogh
|
Post Date:
|
4/19/2006 3:20:26 AM
|
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
|
|
Reply By:
|
mat41
|
Reply Date:
|
4/19/2006 6:25:54 PM
|
;;;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
|