scampercat

scampercat

  • NA
  • 189
  • 0

regular expression validator

Aug 15 2012 3:58 PM
In a C# 2010 web form application, I have a regular expression validator that validates if a date is in mm/dd/yyyy format. The control works fine however the message quickly appears when the user enters the date and goes away. The message also appears when the user clicks the next button. I only want the message to appear when the user clicks the 'next' button.
The following is my code:

<div>     <asp:RegularExpressionValidator ID="RegExpresValdate" runat="server" ControlToValidate="txtDate"   CssClass="errorStyle"
  ValidationExpression="^(0[1-9]|1[012])[/](0[1-9]|[12][0-9]|3[01])[/](19|20)\d\d$"
                                 ErrorMessage="Please enter date in valid format (mm/dd/yyyy).">
                                  </asp:RegularExpressionValidator>
                                </div>

Can you tell me what I can do to have the message only display when the user clicks the next button?

Answers (2)