Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Date vaidation after form submission

Reply
Thread Tools

Date vaidation after form submission

 
 
Simon
Guest
Posts: n/a
 
      10-25-2004
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


 
Reply With Quote
 
 
 
 
thorpe
Guest
Posts: n/a
 
      10-25-2004
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
>
>
>

 
Reply With Quote
 
 
 
 
Mark Schupp
Guest
Posts: n/a
 
      10-25-2004
'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" <(E-Mail Removed)> wrote in message
news:hB8fd.153996$(E-Mail Removed) o.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
>
>



 
Reply With Quote
 
Hal Rosser
Guest
Posts: n/a
 
      10-26-2004
Don't you need to put "#"'s around the literals of a date ?

"Simon" <(E-Mail Removed)> wrote in message
news:hB8fd.153996$(E-Mail Removed) o.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


 
Reply With Quote
 
Simon
Guest
Posts: n/a
 
      10-26-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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> '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" <(E-Mail Removed)> wrote in message
> news:hB8fd.153996$(E-Mail Removed) o.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
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<form>...</form> - how to supress blank space after </form> in IE? rob c Javascript 4 12-30-2005 06:10 PM
Calculate the date after subtracting nmbr of days form a date Laery C Programming 11 02-25-2005 07:59 AM
vaidation and non-server controls Random ASP .Net 2 02-04-2005 07:51 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Form Submission: Final URL that has form options included ?? Jared Javascript 5 07-10-2003 10:33 AM



Advertisments