I have a regular expression control that validates an email address. It validates as expected except that it does it when the control loses focus. I want it to validate only when the form is being submitted.
<asp:TextBox ID="txtRegisterEmailAddress" type="email" ValidationGroup="UserProfile" runat="server" CssClass="form-control " Style="text-transform: lowercase" />
<asp:RegularExpressionValidator ID="revRegisterEmailAddress" runat="server" ControlToValidate="txtRegisterEmailAddress" ErrorMessage="* Invalid Email Address" Display="Dynamic" SetFocusOnError="true" ValidateRequestMode="Disabled" ForeColor="Red" ValidationGroup="UserProfile" ValidationExpression="^(([a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]{2,10}(?:[a-z0-9-]*[a-z0-9])?)\s*?,?\s*?)+$" />
<asp:Button runat="server" ID="btnRegister" ClientIDMode="Static" ValidationGroup="UserProfile" CssClass="btn btn-default" OnClick="btnRegister_Click" Text="Register" OnClientClick="DisableReg();" UseSubmitBehavior="false" />
Please help.
EDIT:
The validation should only happen when I submit, and should not submit if validation fails. Currently it validates when losing focus of the control. I do not want to rewrite the validation process, only change WHEN it validates.