Date validation using Regular Expression in C#.net

Description :


Date validation using Regular expression in c#.net


public static bool DateSyntaxChecker(string InputDate)
{
string strRegex = @"((([0][1-9]|[12][\d])|[3][01])[-]([0][13578]|[1][02])[-][1-9]\d\d\d)|((([0][1-9]|[12][\d])|[3][0])[-]([0][13456789]|[1][012])[-][1-9]\d\d\d)|(([0][1-9]|[12][\d])[-][0][2][-][1-9]\d([02468][048]|[13579][26]))|(([0][1-9]|[12][0-8])[-][0][2][-][1-9]\d\d\d)$";
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(strRegex);
return regex.IsMatch(InputDate);

}


If validate date means function will return true other wise false


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: