Trying to check date entered using validation

Discussion in 'ASP .Net' started by TN Bella, Jun 15, 2004.

  1. TN Bella

    TN Bella Guest

    Trying to check if an entry for an date is < 3 years to current date or
    > 30 days from current date. How can I do this in asp.net....? Do I need

    to use the customvalidation. Can anyone give me an example? Thanks in
    advance for the help

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    TN Bella, Jun 15, 2004
    #1
    1. Advertising

  2. Hi,

    here you have a code snippet:



    <asp:TextBox ID="txt" Runat=server></asp:TextBox>
    <asp:RangeValidator ID="validDate" Type=Date MinimumValue="2004-10-10"
    MaximumValue="2004-10-11" ControlToValidate="txt" EnableClientScript="true"
    ErrorMessage="invalid date" Runat=server Display=Dynamic />
    <asp:ValidationSummary Runat=server
    EnableClientScript=True></asp:ValidationSummary>
    <asp:Button Runat=server ></asp:Button>


    Now the dates a set static but to change this to make them dynamic add
    something like this to the script section of your code:

    validDate.MinimumValue = Now.AddYears(-3)
    validDateMaximumValue = Now.AddDays(30)

    I haven't tested all of this now but the concepts are these...
    Bye
    Cristian


    "TN Bella" <> wrote in message
    news:...
    >
    > Trying to check if an entry for an date is < 3 years to current date or
    > > 30 days from current date. How can I do this in asp.net....? Do I need

    > to use the customvalidation. Can anyone give me an example? Thanks in
    > advance for the help
    >
    > *** Sent via Devdex http://www.devdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Cristian Suazo, Jun 16, 2004
    #2
    1. Advertising

  3. Well that looks good, but can it be globalized?

    Date format seem to vary with cultures. So i doubt the hardcoded date format
    will
    hold when the application should support other cultures.

    But you are totally right if globalization is not an issue for the
    given product.

    Thanks

    J.B



    "Cristian Suazo" <cristiansuazo @ hotmail.com> wrote in message
    news:%...
    > Hi,
    >
    > here you have a code snippet:
    >
    >
    >
    > <asp:TextBox ID="txt" Runat=server></asp:TextBox>
    > <asp:RangeValidator ID="validDate" Type=Date MinimumValue="2004-10-10"
    > MaximumValue="2004-10-11" ControlToValidate="txt"

    EnableClientScript="true"
    > ErrorMessage="invalid date" Runat=server Display=Dynamic />
    > <asp:ValidationSummary Runat=server
    > EnableClientScript=True></asp:ValidationSummary>
    > <asp:Button Runat=server ></asp:Button>
    >
    >
    > Now the dates a set static but to change this to make them dynamic add
    > something like this to the script section of your code:
    >
    > validDate.MinimumValue = Now.AddYears(-3)
    > validDateMaximumValue = Now.AddDays(30)
    >
    > I haven't tested all of this now but the concepts are these...
    > Bye
    > Cristian
    >
    >
    > "TN Bella" <> wrote in message
    > news:...
    > >
    > > Trying to check if an entry for an date is < 3 years to current date or
    > > > 30 days from current date. How can I do this in asp.net....? Do I need

    > > to use the customvalidation. Can anyone give me an example? Thanks in
    > > advance for the help
    > >
    > > *** Sent via Devdex http://www.devdex.com ***
    > > Don't just participate in USENET...get rewarded for it!

    >
    >
     
    bredal Jensen, Jun 16, 2004
    #3
  4. TN Bella

    TN Bella Guest

    Wait...I can't use a variable instead so the date doesn't have to be
    updated each time in the maximum and minimum value?



    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    TN Bella, Jun 16, 2004
    #4
  5. TN Bella

    TN Bella Guest

    Thanks a bunch..>I am going to test it right now. And no, I don't need
    to worry about globalization. I appreciate the input. Thanks again!



    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    TN Bella, Jun 16, 2004
    #5
  6. TN Bella

    TN Bella Guest

    Okay...Thanks Cristian...I just needed to wake up. Thanks a lot for the
    help! Here is what was changed:

    Private Sub Page_Load
    validDate.MinimumValue =
    CDate(DateTime.Now.AddYears(-3).ToShortDateString)
    validDate.MaximumValue =
    CDate(DateTime.Now.AddDays(30).ToShortDateString)
    End Sub

    Have a great day!


    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    TN Bella, Jun 16, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TN Bella
    Replies:
    1
    Views:
    1,502
    TN Bella
    Jul 1, 2004
  2. savvy
    Replies:
    2
    Views:
    434
    savvy
    Jan 3, 2006
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,276
    Michael Borgwardt
    May 30, 2004
  4. S N
    Replies:
    5
    Views:
    676
    Adrienne Boswell
    Mar 16, 2009
  5. Steve Wylie

    Check numbers entered

    Steve Wylie, Jun 22, 2004, in forum: Javascript
    Replies:
    5
    Views:
    120
    Dr John Stockton
    Jun 24, 2004
Loading...

Share This Page