Date vaidation after form submission

S

Simon

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
 
M

Mark Schupp

'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
 
S

Simon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top