26 February 2009

You can apply date format in RegularExpressionValidator

suppose I have a textbox to apply date time by "dd/MM/yyyy" format.

I can use flowing ValidationExpression:

<asp:RegularExpressionValidator
ID="RegularExpressionValidator2"
runat="server"
ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d"
ControlToValidate="myTextBox"
ErrorMessage="Enter date in dd/mm/yyyy format">