Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to validate date format if it is in MM/DD/YYYY format or not in C#.
Please help.
Please note that I dont need validation in Javascript.
Posted

C# has a DateTime.TryParse method[^].
This can help you detect the validity of the date.

Here[^] are some samples.
 
Share this answer
 
Try:
DateTime dt;
if (DateTime.TryParseExact("04/17/2015", "MM/dd/yyyy", CultureInfo("en-US"), DateTimeStyles.None, out dt))
   {
   ...
 
Share this answer
 

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