必填字段校验器在Chrome浏览器和发射; Safari浏览器时,按钮具有的CausesValidation ="假" [英] Required Field Validators firing in Chrome & Safari when button has CausesValidation="false"
问题描述
我有一些问题,我的Chrome浏览器和ASP.NET 4应用程序; Safari浏览器(Firefox和IE工程)。
I'm having some problems with my ASP.NET 4 application in Chrome & Safari (works in Firefox and IE).
我用下面的code按钮宣称:
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" />
在code-隐藏文件我有以下的code:
In the code-behind file I have the following code:
protected void btnEOI_Click(object sender, EventArgs e)
{
Response.Redirect("Default.aspx", true);
}
另外,页面上是有两个RequiredFieldValidators和RegularEx pressionValidator一个LoginControl:
Also on the page is a LoginControl that has two RequiredFieldValidators and a 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>
当我点击Chrome和Safari中,UserNameRequired按钮,PasswordRequired验证器火,即使按钮具有的CausesValidation =假。验证错误不会发生在IE或Firefox。
When I click the button in Chrome and Safari, the UserNameRequired and PasswordRequired validators fire even though the button has CausesValidation="false". The validation errors do not occur in IE or Firefox.
我怎样才能阻止验证程序在Chrome和Firefox射击?
How can I stop the validators from firing in Chrome and Firefox?
推荐答案
原来,我们不得不习惯了被提交表单prevent双击一些JavaScript [0](在这种情况下是登录控制)。
It turns out that we had some javascript used to prevent double-clicking that was submitting form[0] (which in this case is the login control).
这篇关于必填字段校验器在Chrome浏览器和发射; Safari浏览器时,按钮具有的CausesValidation =&QUOT;假&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!