【发布时间】:2014-01-20 01:22:48
【问题描述】:
我在 asp.net 中开发了一个应用程序,在我的页面上有一个必填字段的复选框,我在验证后进行编码,但按保存验证没有调用。
<asp:CheckBox ID="ChkContent" runat="server" Text=" I hereby certify that the information above is true and accurate."
Font-Bold="true" />
<asp:CustomValidator ID="Custom1" CssClass="errorTop" ClientValidationFunction="CheckBoxValidation" runat="server"
ErrorMessage="You must select this box to proceed" ></asp:CustomValidator>
保存按钮代码是
<asp:Button ID="BtnSaveMiscDetail" ValidationGroup="AddMisc" CssClass="buttonGrid"
runat="server" Text="Save" Width="60px" OnClick="BtnSaveMiscDetail_Click" />
客户端验证码是
function CheckBoxValidation(oSrouce, args) {
var myCheckBox = document.getElementById("ContentPlaceHolder1_MiscDetails1_ChkContent");
if (myCheckBox.checked) {
args.IsValid = true;
}
else
args.IsValid = false;
}
验证函数没有调用。
【问题讨论】:
-
在您的自定义验证器控件中添加
ValidationGroup="AddMisc"。
标签: c# javascript asp.net validation checkbox