Regular expression for MM/DD/YYYY date textbox

Posted by Sheonarayan under ASP.NET category on | Points: 40 | Views : 807
To force MM/DD/YYYY date in the TextBox, we can use pattern attribute of the textbox (html 5).

<input type="tex" pattern="^(0[1-9]|1[0-2])[- /.](0[1-9]|1\d|2\d|3[01])[- /.](19|20)\d{2}$" name="BOD" />

Or in ASP.NET, use asp:RegularExpressionValidator and use "^(0[1-9]|1[0-2])[- /.](0[1-9]|1\d|2\d|3[01])[- /.](19|20)\d{2}$ " regular expression as ValidationExpression.

Read more about asp:ReguarlExpressionValidator at


Comments or Responses

Login to post response