为什么我的自定义验证火? [英] Why won't my custom validator fire?

查看:147
本文介绍了为什么我的自定义验证火?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET web应用程序。我基本上tryign说用户必须输入eitehr的公司名称或所有者的名称。我有我的网页,并在网页上是与文本字段和一个自定义的控制用户的控制。下面是自定义的控制和验证摘要...

 < ASP:的ValidationSummary ID =ValidationSummary1=服务器
的CssClass =failureNotification的ValidationGroup =OwnerInfo/>< ASP:的CustomValidator ID =CustomValidator1=服务器
ClientValidationFunction =CheckOwner的ControlToValidate =txtCompany
的ErrorMessage =公司名称或业主需要的ValidationGroup =OwnerInfo> * LT; / ASP:的CustomValidator>

即使剥离下来的实际,以最低限度的JavaScript功能,并在这两个控件本身和主要页面的Headcontent部分尝试它,我不能让它火。这里是javascript函数...

 <脚本类型=文/ JavaScript的>
    功能CheckOwner(来源参数){
        args.IsValid = FALSE;    }
< / SCRIPT>


解决方案

您试图让它火空文?是所以你需要设置ValidateEmptyText属性。

I have an ASP.NET web app. I am basically tryign to say a user has to enter eitehr the company name or the owner's name. I have my web page, and on the web page is a user control with those text fields and a custom control. Here is the custom control and validation summary...

<asp:ValidationSummary ID="ValidationSummary1" runat="server"  
CssClass="failureNotification" ValidationGroup="OwnerInfo" />

<asp:CustomValidator ID="CustomValidator1" runat="server" 
ClientValidationFunction="CheckOwner" ControlToValidate="txtCompany" 
ErrorMessage="Company Name or Owner required" ValidationGroup="OwnerInfo">*</asp:CustomValidator>

Even stripping the actual javascript function down to the bare minimum and trying it in both the control itself and the Headcontent section of the main page, I can't get it to fire. Here is the javascript function...

<script type="text/javascript">
    function CheckOwner(source, args) {
        args.IsValid = false;

    }
</script>

解决方案

Are you trying to get it to fire for empty text? Is so you need to set the ValidateEmptyText property.

这篇关于为什么我的自定义验证火?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆