Date vaidation after form submission

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon

    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("E xpiresDDin")
    ExpiresMM = Request.Form("E xpiresMMin")
    ExpiresYY = Request.Form("E xpiresYYin")

    '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

    #2
    RE: Date vaidation after form submission

    you need to look into the 'dateadd' function.

    "Simon" wrote:
    [color=blue]
    > 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("E xpiresDDin")
    > ExpiresMM = Request.Form("E xpiresMMin")
    > ExpiresYY = Request.Form("E xpiresYYin")
    >
    > '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
    >
    >
    >[/color]

    Comment

    • Mark Schupp

      #3
      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



      "Simon" <simon.cornfort h@blueyonder.co .uk> wrote in message
      news:hB8fd.1539 96$BI5.127858@f e2.news.blueyon der.co.uk...[color=blue]
      > Hi there.
      >
      > I have a form on which I have a date of expiry which is built from 3[/color]
      select[color=blue]
      > 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("E xpiresDDin")
      > ExpiresMM = Request.Form("E xpiresMMin")
      > ExpiresYY = Request.Form("E xpiresYYin")
      >
      > '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
      >
      >[/color]


      Comment

      • Hal Rosser

        #4
        Re: Date vaidation after form submission

        Don't you need to put "#"'s around the literals of a date ?

        "Simon" <simon.cornfort h@blueyonder.co .uk> wrote in message
        news:hB8fd.1539 96$BI5.127858@f e2.news.blueyon der.co.uk...[color=blue]
        > Hi there.
        >
        > I have a form on which I have a date of expiry which is built from 3[/color]
        select[color=blue]
        > 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("E xpiresDDin")
        > ExpiresMM = Request.Form("E xpiresMMin")
        > ExpiresYY = Request.Form("E xpiresYYin")
        >
        > '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
        >
        >[/color]


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


        Comment

        • Simon

          #5
          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@ielear ning.com> wrote in message
          news:e7xZsTruEH A.2192@TK2MSFTN GP14.phx.gbl...[color=blue]
          > '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.cornfort h@blueyonder.co .uk> wrote in message
          > news:hB8fd.1539 96$BI5.127858@f e2.news.blueyon der.co.uk...[color=green]
          > > Hi there.
          > >
          > > I have a form on which I have a date of expiry which is built from 3[/color]
          > select[color=green]
          > > fields to build the day, month and year, this all works OK and the data[/color][/color]
          is[color=blue][color=green]
          > > 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("E xpiresDDin")
          > > ExpiresMM = Request.Form("E xpiresMMin")
          > > ExpiresYY = Request.Form("E xpiresYYin")
          > >
          > > '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
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...