473,326 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

validating date of birth

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
1 1983
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Gav | last post by:
I have a database with date of births stored dd/mm/yyyy (english dating system) and =date() returns a date in the same format in my server. how do i find the persons age using these two pieces of...
16
by: KL | last post by:
I am working on a problem and desperately need help! I need to prompt a user for the numerical month of birth, day of birth and year of birth and store it in varialbes and the use the variables...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
2
by: Patrick.O.Ige | last post by:
I'm using this CompareValidator to validate dates but my default its mm/dd/yyyy <asp:CompareValidator ControlToValidate="DOB" Display="Dynamic" Text="Invalid birth date!" Operator="DataTypeCheck"...
2
by: Matuag | last post by:
Hi All, I am trying to create a form which can calculate with Age and Birth Date fields. I want Age to be calculated based on Birth Date (which I managed to do) but at the same time if Birth...
1
by: aheine | last post by:
Hey! So i have a program i need to write that must include the user to input their birthdate (mm-dd-yyyy) . Then i must validate the input from the user, meaning i need to check to make sure the...
3
by: jamieharrop | last post by:
Afternoon all, I've been battling with this all day today and my brain is now pretty much fried. I have one table that lists several details about my customers (name, address, phone, date of...
1
by: jocelyn88 | last post by:
I would like to identify the Date of Birth, Gender and Age of a Malaysian by extraction the information from the new IC number. The object calculate the Date of Birth, Gender and Age. For example,...
1
by: karimufeed | last post by:
I am working on an access project for pension calculation. I want to generate the retirement date automatically at the age of 60 years while filling the date of Birth. i.e. if the Date of birth is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.