By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,819 Members | 1,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,819 IT Pros & Developers. It's quick & easy.

validating date of birth

P: n/a
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 ***
Feb 12 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Feb 12, 8:01 am, Eugene Anthony <solomon_13...@yahoo.comwrote:
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);

Feb 12 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.