客户端自定义的验证

编程入门 行业动态 更新时间:2024-10-27 21:21:57
本文介绍了客户端自定义的验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图做客户端自定义验证。我在我的aspx页面下面的code,但我不断收到一个错误说

I am trying to do client side custom validation. I have the following code in my aspx page, but I keep getting an error saying

System.Web.HttpException(0X80004005):控制chkList_Counts  通过validationCheck的ControlToValidate属性引用  无法验证。在  System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(字符串  名,弦乐propertyName的)在  System.Web.UI.WebControls.CustomValidator.ControlPropertiesValid()在  System.Web.UI.WebControls.BaseValidator.On preRender(EventArgs e)上  在

System.Web.HttpException (0x80004005): Control 'chkList_Counts' referenced by the ControlToValidate property of 'validationCheck' cannot be validated. at System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) at System.Web.UI.WebControls.CustomValidator.ControlPropertiesValid() at System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at

我甚至不能看到我的网页。我得到的错误就在在显示页面之前。

I cannot even see my page. I get the error right away before the page displays.

下面是我的code

<div> <asp:Panel ID="panel3" runat="server" CssClass="cis_edit_pnl" GroupingText="Counts" Width="1240px"> <asp:CheckBoxList ID="chkList_Counts" runat="server" RepeatDirection="Horizontal" RepeatColumns="3" Width="1060px"> </asp:CheckBoxList> <asp:CustomValidator ID="validationCheck" runat="server" ControlToValidate="chkList_Counts" ClientValidationFunction="check_checkBoxList" EnableClientScript="true" ErrorMessage="At least one of the check boxes should be checked"> </asp:CustomValidator> </asp:Panel> </div>

和我的javascript函数是这样的。

and my javascript function is like this

function check_checkBoxList(sender, args) { debugger; if (check_Counts() == false) { args.IsValid = false; return; } args.IsValid = true; return; } function check_casrepCounts() { var control; control = document.getElementById("<%=chkList_Counts.ClientID %>").getElementsByTagName("input"); if (eval(control)) { for (var i = 0; i < control.length; i++) { if (control[i].checked == true) return true; } return false; } }

先谢谢了。

推荐答案

它正常工作,现在,我不得不删除的ControlToValidate和它的工作。

It works fine now, I just had to remove controlToValidate and it worked.

更多推荐

客户端自定义的验证

本文发布于:2023-08-07 15:03:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319760.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   客户端

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!