check format of date input
-
hi How do i go about checking the format of the date that a user entered in a textbox? The date will be their date of birth. I want to make sure it is a valid date. Please someone help me.
DateTime date;
bool isValidDate = DateTime.TryParse(userInputString, out date);There are also regular expressions, but DateTime.TryParse may suit you just fine.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: And in this corner, the Party of Allah The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
DateTime date;
bool isValidDate = DateTime.TryParse(userInputString, out date);There are also regular expressions, but DateTime.TryParse may suit you just fine.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: And in this corner, the Party of Allah The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Judah Himango wrote:
There are also regular expressions
I wouldn't like to try to write a regular expression that can check if a date is valid. Just the expression to check for the different number of days in the months would be horrific, not to speak of leap years... :)
--- b { font-weight: normal; }