Home > Archive > ASP > October 2004 > Date vaidation after form submission
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Date vaidation after form submission
|
|
|
| Hi there.
I have a form on which I have a date of expiry which is built from 3 select
fields to build the day, month and year, this all works OK and the data is
being built and added to the database no problem.
However, I want to validate this date to ensure it is in the future, the
following validation does not work, any ideas?
'get data from form
ExpiresDD = Request.Form("ExpiresDDin")
ExpiresMM = Request.Form("ExpiresMMin")
ExpiresYY = Request.Form("ExpiresYYin")
'build the date
Expires = ExpiresDD & "/" & ExpiresMM & "/" & ExpiresYY
'validate for in the future
if Expires <= Date then
errorSameDate = "True"
errorTrap = "True"
end if
I have also tried isDate(Expires) to check if todays date, as in, but no
luck again, obvs submitting todays date!
if isDate(Expires) then
errorSameDate = "True"
errorTrap = "True"
end if
Hope someone can help.
Cheers
Simon
| |
| thorpe 2004-10-25, 3:55 pm |
| you need to look into the 'dateadd' function.
"Simon" wrote:
> Hi there.
>
> I have a form on which I have a date of expiry which is built from 3 select
> fields to build the day, month and year, this all works OK and the data is
> being built and added to the database no problem.
>
> However, I want to validate this date to ensure it is in the future, the
> following validation does not work, any ideas?
>
> 'get data from form
> ExpiresDD = Request.Form("ExpiresDDin")
> ExpiresMM = Request.Form("ExpiresMMin")
> ExpiresYY = Request.Form("ExpiresYYin")
>
> 'build the date
> Expires = ExpiresDD & "/" & ExpiresMM & "/" & ExpiresYY
>
> 'validate for in the future
> if Expires <= Date then
> errorSameDate = "True"
> errorTrap = "True"
> end if
>
> I have also tried isDate(Expires) to check if todays date, as in, but no
> luck again, obvs submitting todays date!
>
> if isDate(Expires) then
> errorSameDate = "True"
> errorTrap = "True"
> end if
>
> Hope someone can help.
>
> Cheers
>
> Simon
>
>
>
| |
| Mark Schupp 2004-10-25, 3:55 pm |
| 'validate for in the future
if CDate(Expires) <= Date then
errorSameDate = "True"
errorTrap = "True"
end if
You might want to use a non-ambiguous date format as well before you get
bitten by the UK vs US date format differences
Expires = "20" & ExpiresYY & "-" & ExpiresMM & "-" & ExpiresDD
If not IsDate(Expires) Then
'put bad date error code here
End If
--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Simon" <simon.cornforth@blueyonder.co.uk> wrote in message
news:hB8fd.153996$BI5.127858@fe2.news.blueyonder.co.uk...
> Hi there.
>
> I have a form on which I have a date of expiry which is built from 3
select
> fields to build the day, month and year, this all works OK and the data is
> being built and added to the database no problem.
>
> However, I want to validate this date to ensure it is in the future, the
> following validation does not work, any ideas?
>
> 'get data from form
> ExpiresDD = Request.Form("ExpiresDDin")
> ExpiresMM = Request.Form("ExpiresMMin")
> ExpiresYY = Request.Form("ExpiresYYin")
>
> 'build the date
> Expires = ExpiresDD & "/" & ExpiresMM & "/" & ExpiresYY
>
> 'validate for in the future
> if Expires <= Date then
> errorSameDate = "True"
> errorTrap = "True"
> end if
>
> I have also tried isDate(Expires) to check if todays date, as in, but no
> luck again, obvs submitting todays date!
>
> if isDate(Expires) then
> errorSameDate = "True"
> errorTrap = "True"
> end if
>
> Hope someone can help.
>
> Cheers
>
> Simon
>
>
| |
| Hal Rosser 2004-10-26, 3:55 am |
| Don't you need to put "#"'s around the literals of a date ?
"Simon" <simon.cornforth@blueyonder.co.uk> wrote in message
news:hB8fd.153996$BI5.127858@fe2.news.blueyonder.co.uk...
> Hi there.
>
> I have a form on which I have a date of expiry which is built from 3
select
> fields to build the day, month and year, this all works OK and the data is
> being built and added to the database no problem.
>
> However, I want to validate this date to ensure it is in the future, the
> following validation does not work, any ideas?
>
> 'get data from form
> ExpiresDD = Request.Form("ExpiresDDin")
> ExpiresMM = Request.Form("ExpiresMMin")
> ExpiresYY = Request.Form("ExpiresYYin")
>
> 'build the date
> Expires = ExpiresDD & "/" & ExpiresMM & "/" & ExpiresYY
>
> 'validate for in the future
> if Expires <= Date then
> errorSameDate = "True"
> errorTrap = "True"
> end if
>
> I have also tried isDate(Expires) to check if todays date, as in, but no
> luck again, obvs submitting todays date!
>
> if isDate(Expires) then
> errorSameDate = "True"
> errorTrap = "True"
> end if
>
> Hope someone can help.
>
> Cheers
>
> Simon
>
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.781 / Virus Database: 527 - Release Date: 10/22/2004
| |
|
| Thanks for that, again I managed a work around, but that was cleaner and
less code.
Luckily, in this case as well, the server and the users are in the UK, so no
US date issues.
Cheers
Simon
"Mark Schupp" <mschupp@ielearning.com> wrote in message
news:e7xZsTruEHA.2192@TK2MSFTNGP14.phx.gbl...
> 'validate for in the future
> if CDate(Expires) <= Date then
> errorSameDate = "True"
> errorTrap = "True"
> end if
>
> You might want to use a non-ambiguous date format as well before you get
> bitten by the UK vs US date format differences
>
> Expires = "20" & ExpiresYY & "-" & ExpiresMM & "-" & ExpiresDD
> If not IsDate(Expires) Then
> 'put bad date error code here
> End If
>
> --
> Mark Schupp
> Head of Development
> Integrity eLearning
> www.ielearning.com
>
>
> "Simon" <simon.cornforth@blueyonder.co.uk> wrote in message
> news:hB8fd.153996$BI5.127858@fe2.news.blueyonder.co.uk...
> select
is[color=darkred]
>
>
|
|
|
|
|