validating date of birth

Discussion in 'ASP .Net' started by Eugene Anthony, Feb 12, 2007.

  1. I tried validating my dob using the code bellow however I keep getting
    the message "Enter a valid dob" despite entering a valid dob.


    String dob = TextBox6.Text + "/" + TextBox7.Text + "/" + TextBox8.Text;

    try
    {
    DateTime dt = DateTime.Parse(dob);
    }
    catch (FormatException)
    {
    Label9.Text = "Enter a valid dob";
    return;
    }


    How do I solve the problem?


    Your help is kindly appreciate.


    Eugene Anthony

    *** Sent via Developersdex http://www.developersdex.com ***
    Eugene Anthony, Feb 12, 2007
    #1
    1. Advertising

  2. On Feb 12, 8:01 am, Eugene Anthony <> wrote:
    > I tried validating my dob using the code bellow however I keep getting
    > the message "Enter a valid dob" despite entering a valid dob.
    >
    > String dob = TextBox6.Text + "/" + TextBox7.Text + "/" + TextBox8.Text;
    >
    > try
    > {
    > DateTime dt = DateTime.Parse(dob);}
    >
    > catch (FormatException)
    > {
    > Label9.Text = "Enter a valid dob";
    > return;
    >
    > }
    >
    > How do I solve the problem?
    >


    Which culture settings do you have?

    Try this

    System.Globalization.CultureInfo culture = new
    System.Globalization.CultureInfo("en-GB"); // change it to you culture
    DateTime a =
    DateTime.Parse("18/09/2004",culture,System.Globalization.DateTimeStyles.NoCurrentDateDefault);
    Alexey Smirnov, Feb 12, 2007
    #2
    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. TJS
    Replies:
    9
    Views:
    16,165
    gosborne
    Sep 7, 2010
  2. Rick North

    Birth date for VHDL 87 ?

    Rick North, Jan 19, 2007, in forum: VHDL
    Replies:
    2
    Views:
    413
    Rick North
    Jan 20, 2007
  3. les

    Calendar control to select data of birth?

    les, Dec 27, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    219
    Jason
    Dec 29, 2003
  4. Gav

    Finding Age from Date of Birth

    Gav, Jan 4, 2004, in forum: ASP General
    Replies:
    20
    Views:
    380
    Guest
    Jan 5, 2004
  5. eggie5

    Age to birth year

    eggie5, Sep 25, 2007, in forum: Ruby
    Replies:
    2
    Views:
    92
    Jan Friedrich
    Sep 25, 2007
Loading...

Share This Page