禁止使用JavaScript ASP.NET 1.1验证 - 在Firefox中不工作 [英] Disable ASP.NET 1.1 Validator using JavaScript - Not Working in Firefox
问题描述
下面的尝试工作在IE8,但不能在Firefox(不能使用JQuery此):
The following attempt works in IE8 but not in Firefox (cannot use JQuery for this):
case 'Template:templateControl:residenceRBL2':
if (selected.value == 'Within USA')
{
/* Enable zip textbox and validator */
document.getElementById("Template_templateControl_zipTxt1").disabled=false;
ValidatorEnable(document.getElementById('<%=firstPersonZipReqVal.ClientID%>'),
true);
...
}
else if (selected.value == 'Outside USA')
{
/* Disable zip textbox and validator */
document.getElementById("Template_templateControl_zipTxt1").disabled=true;
ValidatorEnable(document.getElementById('<%=firstPersonZipReqVal.ClientID%>'),
false);
...
}
break;
<asp:Label ID="firstPersonZipLabel" Runat="server"></asp:Label><br />
<asp:TextBox ID="zipTxt1" Height="19" Width="100"
Runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="firstPersonZipReqVal"
ControlToValidate="zipTxt1" Display="Dynamic"
ErrorMessage="First Person Zip"
Runat="server">*</asp:RequiredFieldValidator>
问题描述:取决于RadioButtonList的选择,需要禁用验证程序/一个TextBox重新启用。基本上,如果他们的地址是美国以外,则压缩文本框验证被禁用。在Firefox中,这将根本无法工作。
Description of problem: depending on a radiobuttonlist selection, a required validator is disabled/re-enabled for a textbox. Basically, if their address is outside USA, then the zip textbox validator is disabled. In Firefox, this will not work at all.
更新1:2010年9月7日
我在Firefox中禁用文本框;我用的name属性,而不是ID。我唯一的问题是现在如何访问一个JS验证ASP.NET控件的客户端ID?
UPDATE 1: 09-07-2010 I got the textbox disabled in Firefox; I was using the name attribute instead of the id. My only issue now is how to access the "ClientID" of an ASP.NET validator control in JS?
更新2:2010年9月7日
按照 MSDN文档,我想我可以做这样的事情
UPDATE 2: 09-07-2010 Per the MSDN documentation, I thought I could do something like this:
ValidatorEnable(firstPersonZipReqVal, false);
可惜,这似乎并没有在Firefox工作要么...
Unfortunately this doesn't seem to work in Firefox either...
<一个href=\"http://stackoverflow.com/questions/422554/asp-net-broken-rendering-of-validation-client-side-$c$c-in-firefox\">http://stackoverflow.com/questions/422554/asp-net-broken-rendering-of-validation-client-side-$c$c-in-firefox
更新3:2010年9月8日
原因Firefox是不打漂亮是因为ASP.NET 1.1把它当作一个低级别的浏览器。如果我在页面标签把clientTarget =upLevel,作品如预期Firefox浏览器。不幸的是,这打破了整个网站的布局。 是否有固定的browserCaps用于Firefox 的的browserCaps的这个版本也打破了布局。
The reason Firefox is not playing nice is because ASP.NET 1.1 is treating it as a down-level browser. If I put clientTarget="upLevel" in the Page tag, Firefox works as expected. Unfortunately, this breaks the entire site layout. Is there a more gradual way to fix the browsercaps for Firefox? This version of browserCaps also breaks the layout.
在Web.Config中看起来就像这样当前的browserCaps:
Current browserCaps in Web.Config look like this:
<browserCaps>
<case match="Gecko/[-\d]+">
browser=Netscape
frames=true
tables=true
cookies=true
javascript=true
javaapplets=true
ecmascriptversion=1.5
w3cdomversion=1.0
css1=true
css2=true
xml=true
tagwriter=System.Web.UI.HtmlTextWriter
<case match="rv:1.0[^\.](?'letters'\w*)">
version=6.0
majorversion=6
minorversion=0
<case match="^b" with="${letters}">
beta=true
</case>
</case>
<case match="rv:1(\.\d+)(\.\d)?(?'letters'\w*)">
version=7.0
majorversion=7
minorversion=0
<case match="^b" with="${letters}">
beta=true
</case>
</case>
</case>
</browserCaps>
更新:2010年9月11日
以下链接可以提供答案;有人可以协助code为50分?
The following link may provide the answer; can someone assist with the code for the 50 points?
http://www.4guysfromrolla.com/articles/051204-1.aspx
推荐答案
标记为答案 - 看到这个上面的链接斯科特·米切尔的文章
Marked as answer - see link to Scott Mitchell's article on this above.
这篇关于禁止使用JavaScript ASP.NET 1.1验证 - 在Firefox中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!