Regular expression to validate date in MM/DD/YYYY format.

Virendradugar
Posted by Virendradugar under ASP.NET category on | Views : 30478
 <asp:TextBox ID="txtDate" runat="server"></asp:TextBox>

<asp:RegularExpressionValidator ID="regPurchaseDate" runat="server" Display="None"
ErrorMessage="Please enter date in valid format(mm/dd/yyyy)." ValidationGroup="CheckVal"
ControlToValidate="txtDate" SetFocusOnError="true" ValidationExpression="^(((0?[1-9]|1[012])/(0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])/(29|30)|(0?[13578]|1[02])/31)/(19|[2-9]\d)\d{2}|0?2/29/((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))$"></asp:RegularExpressionValidator>

Comments or Responses

Login to post response