Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > validating date of birth

Reply
Thread Tools

validating date of birth

 
 
Eugene Anthony
Guest
Posts: n/a
 
      02-12-2007
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 ***
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      02-12-2007
On Feb 12, 8:01 am, Eugene Anthony <(E-Mail Removed)> 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);

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
calculate age from date of birth TJS ASP .Net 9 09-07-2010 05:08 PM
Birth date for VHDL 87 ? Rick North VHDL 2 01-20-2007 08:24 AM
Introduction to FB-DIMM Memory: Birth of Serial RAM? Silverstrand Front Page News 3 07-09-2005 04:57 AM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Finding Age from Date of Birth Gav ASP General 20 01-05-2004 09:01 AM



Advertisments