Use validator to validate date in distinct countries

Discussion in 'ASP .Net' started by Fernando Lopes, Nov 19, 2004.

  1. Hi.
    How can i validate a date textbox using validator, but the validator need to
    validate all data types, like:

    USA: 11/19/2004
    BRAZIL: 19/11/2004
    GERMANY: 19.11.2004

    So, in the validator message, i need to show how is the mask according the
    country.
    If my application is running in USA, and the user type 19/11/2004, the error
    message will be:
    Incorrect date. Please use this mask: MM/DD/YYYY, but if my application
    running in Brazil, no error message will be raise.

    I hope somebody understand me.

    Thanks.

    Fernando Lopes
    Fernando Lopes, Nov 19, 2004
    #1
    1. Advertising

  2. I believe this can be accomplished by change the localization of the thread.

    Take a look at this article.

    http://samples.gotdotnet.com/quicks...l=/quickstart/aspplus/doc/localizingapps.aspx

    I believe the validator will pickup on the culture change and validate
    appropriately.

    "Fernando Lopes" wrote:

    > Hi.
    > How can i validate a date textbox using validator, but the validator need to
    > validate all data types, like:
    >
    > USA: 11/19/2004
    > BRAZIL: 19/11/2004
    > GERMANY: 19.11.2004
    >
    > So, in the validator message, i need to show how is the mask according the
    > country.
    > If my application is running in USA, and the user type 19/11/2004, the error
    > message will be:
    > Incorrect date. Please use this mask: MM/DD/YYYY, but if my application
    > running in Brazil, no error message will be raise.
    >
    > I hope somebody understand me.
    >
    > Thanks.
    >
    > Fernando Lopes
    >
    >
    >
    =?Utf-8?B?TWlrZUw=?=, Nov 19, 2004
    #2
    1. Advertising

  3. Fernando Lopes

    Peter Blum Guest

    MikeL is correct that you need to set the CultureInfo on the current thread.
    The only part missing is the validation:
    Use a CompareValidator with its Operator=DataTypeCheck and Type="Date". It
    respects the CultureInfo of the current thread.

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "MikeL" <> wrote in message
    news:...
    >I believe this can be accomplished by change the localization of the
    >thread.
    >
    > Take a look at this article.
    >
    > http://samples.gotdotnet.com/quicks...l=/quickstart/aspplus/doc/localizingapps.aspx
    >
    > I believe the validator will pickup on the culture change and validate
    > appropriately.
    >
    > "Fernando Lopes" wrote:
    >
    >> Hi.
    >> How can i validate a date textbox using validator, but the validator need
    >> to
    >> validate all data types, like:
    >>
    >> USA: 11/19/2004
    >> BRAZIL: 19/11/2004
    >> GERMANY: 19.11.2004
    >>
    >> So, in the validator message, i need to show how is the mask according
    >> the
    >> country.
    >> If my application is running in USA, and the user type 19/11/2004, the
    >> error
    >> message will be:
    >> Incorrect date. Please use this mask: MM/DD/YYYY, but if my application
    >> running in Brazil, no error message will be raise.
    >>
    >> I hope somebody understand me.
    >>
    >> Thanks.
    >>
    >> Fernando Lopes
    >>
    >>
    >>
    Peter Blum, Nov 19, 2004
    #3
    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. Grey
    Replies:
    3
    Views:
    13,654
    grish
    Oct 9, 2012
  2. Marcus Leon
    Replies:
    1
    Views:
    3,288
    Marcus Leon
    Jun 30, 2003
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,244
    Michael Borgwardt
    May 30, 2004
  4. Hicham Mouline
    Replies:
    1
    Views:
    390
    Kai-Uwe Bux
    Apr 11, 2010
  5. Shailesh Katti

    compare validator to validate date in user control

    Shailesh Katti, Jul 27, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    701
    Teemu Keiski
    Jul 28, 2003
Loading...

Share This Page