I’m trying to write a custom ASP.NET field validator which makes sure the input is a valid date on the format “yyMMdd”.
How do I do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can try
DateTime.ParseExact("091223", "yyMMdd", CultureInfo.InvariantCulture);EDIT
Woops, sorry, didn’t see the ASP.NET bit. AFAIK you can make custom validators in ASP.NET? This could be the base of it, and there is also a “TryParseExact” version of the DateTime call, which would allow you to check without exception.