Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
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



Report this thread to moderator Post Follow-up to this message
Old Post
Simon
10-25-04 08:55 PM


RE: Date vaidation after form submission
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 selec
t
> 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
>
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
thorpe
10-25-04 08:55 PM


Re: Date vaidation after form submission
'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
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Mark Schupp
10-25-04 08:55 PM


Re: Date vaidation after form submission
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



Report this thread to moderator Post Follow-up to this message
Old Post
Hal Rosser
10-26-04 08:55 AM


Re: Date vaidation after form submission
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 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Simon
10-26-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

ASP archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:50 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.