Click here to Skip to main content
15,914,162 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I made a particular program of resume, but I have a problem
in my program. I take a masktaskbok of showing date of birth but user inserts date of birth that is invalid that is accepted in the program. But I want date of birth to be valid, so please give code of this problem.
Thank you........
Posted
Updated 13-Mar-10 8:46am
v2

You can test the value entered to see if it is a valid date using
DateTime.Parse() and catch any exception thrown. The function will try to parse the users date string into a DateTime object.
 
Share this answer
 
v2
Use CompareValidator and set Type to Date.
 
Share this answer
 
Here's an idea. If it's a GUI application, then you may use 3 comboboxes and then give them values when the form load say for dates you can use the code in form load:

for(int i =1;i<=31;i++)
{
cbodate.Items.Add(i);
}


And then you may use if else if condition statement to check in the date of birth value, say you can impose a restriction if the user enters 31st of Feb using this conditional statement you may show a messagebox if the user enters a wrong date, or wrong month containing a wrong date say 31st april.

Now if it's an ASP.NET application, then my friend I may suggest you to use the same trick or use any validating ctrls available in the framework.

This is just another method of doing what you want to do but if you insist on using maskedtxtbx, then I have no suggestions on that..... or you can also use DATETIMEPICKER and set validations accordingly...

Thanks & regards,
Radix :-\

Do rate my answer if you find it helpful to some extent. Thank you.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900