Mandatory field validators run in Chrome & Safari when the button has CausesValidation = "false"

I am having problems with my ASP.NET 4 application in Chrome and Safari (works in Firefox and IE).

I have a button declared using the following code:

<asp:Button ID="btnEOI1" runat="server" CssClass="buttonCSS" Text="Lodge an Expression of Interest" OnClick="btnEOI_Click" CausesValidation="False" /> 

In the code file, I have the following code:

 protected void btnEOI_Click(object sender, EventArgs e) { Response.Redirect("Default.aspx", true); } 

Also on the page is LoginControl, which has two RequiredFieldValidators and RegularExpressionValidator:

 <asp:requiredfieldvalidator id="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="Please enter your User Name." SetFocusOnError="true" Display="None"> </asp:requiredfieldvalidator> <asp:RegularExpressionValidator runat="server" id="RegularExpressionValidator1" ControlToValidate="UserName" ErrorMessage="Please enter your User Name without spaces." ValidationExpression="[\S]+" Display="None" SetFocusOnError="true" > </asp:RegularExpressionValidator> <asp:requiredfieldvalidator id="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Please enter your Password." SetFocusOnError="true" Display="None"> </asp:requiredfieldvalidator> 

When I click a button in Chrome and Safari, the UserNameRequired and PasswordRequired validators work, although the button has CausesValidation = "false". Validation errors do not occur in IE or Firefox.

How can I stop the validators from starting in Chrome and Firefox?

+1
source share
3 answers

Turns out we had some javascript used to prevent the double-click that sent form [0] (which in this case is an input control).

+1
source

I just checked your code on a blank page and it works correctly in all browsers.

However, you can try using Verification Groups .

Just set the same group for UserNameRequired, RegularExpressionValidator1, PasswordRequired and your login button.

+1
source

I'm not sure if this applies to your problem, but I found issues with RequiredFieldValidators with Display="Dynamic" for it.

Removal is fixed with a problem in which some validators did not display correctly in Chrome . While in the past there were other cases where the addition helped solve the problem.

0
source

All Articles