gpt4 book ai didi

javascript - Null Page_Validators 在触发 asp 按钮 onclick 时导致错误

转载 作者:行者123 更新时间:2023-11-28 06:57:28 25 4
gpt4 key购买 nike

我有一个 asp 按钮,用于提交带有一些后端验证的表单

<asp:button id="btnAdd" visible="true" runat="server" ValidationGroup="ETAFAdd"  text="Add &#187;" CssClass="formBut addEmailButton" causesvalidation="true" />
&nbsp; <a id="hoverover" style="cursor:default;" onmouseover="ShowPopup(this);" onmouseout="HidePopup();">

及其提交的字段:

<td valign="top">
<asp:textbox id="txtToName" CssClass="iField txtToName" runat="server" ValidationGroup="ETAFAdd" />
<asp:RequiredFieldValidator runat="server" ID="rfvToName"
ControlToValidate="txtToName"
ValidationGroup="ETAFAdd"
Display="Dynamic"
ErrorMessage="<b>Required Field Missing</b><br />A name is required." />
<ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="vceToName"
TargetControlID="rfvToName"
HighlightCssClass="validatorCalloutHighlight" />
</td>
<td valign="top">
<asp:textbox id="txtToEmail" CssClass="iField txtToEmail" runat="server" ValidationGroup="ETAFAdd"/>
<asp:RequiredFieldValidator runat="server" ID="rfvToEmail"
ControlToValidate="txtToEmail"
ValidationGroup="ETAFAdd"
Display="Dynamic"
ErrorMessage="<b>The email address you entered is invalid.</b><br />Example: name@wimco.com" />
<ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="vceToEmail"
TargetControlID="rfvToEmail"
HighlightCssClass="validatorCalloutHighlight" />
</td>

当我点击asp按钮时,它就起作用了。我尝试在页面上添加另一个按钮,通过 onclick 触发 asp 按钮

$(".formBut.addEmailButton").click();

但是在 ScriptResource 验证中发生了 javascript 错误;前两个 Page_Validators 为 null,我不知道为什么,这些 null 对象会引发错误。这是尝试运行的函数:

function Page_ClientValidate(validationGroup) {
Page_InvalidControlToBeFocused = null;
if (typeof(Page_Validators) == "undefined") {
return true;
}
var i;
for (i = 0; i < Page_Validators.length; i++) {
ValidatorValidate(Page_Validators[i], validationGroup, null);
}
ValidatorUpdateIsValid();
ValidationSummaryOnSubmit(validationGroup);
Page_BlockSubmit = !Page_IsValid;
return Page_IsValid;
}

空 Page_Validators 来自哪里?

最佳答案

检查验证器是否为空。

if (validators != null) {
var i;
for (i = 0; i < Page_Validators.length; i++) {
ValidatorValidate(Page_Validators[i], validationGroup, null);
}
}

关于javascript - Null Page_Validators 在触发 asp 按钮 onclick 时导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32461794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com