ASP.NET验证控件CustomValidator客户端验证DROPDOWNLIST、TEXTBOX

来源:互联网 发布:好的电商美工待遇 编辑:程序博客网 时间:2024/05/14 02:17


验证dropdownlist

view plaincopy to clipboardprint?
function chkddl(source, args){  
            if(args.Value=="0")  
                args.IsValid = false;  
            else 
                args.IsValid=true;  
        } 
function chkddl(source, args){
            if(args.Value=="0")
                args.IsValid = false;
            else
                args.IsValid=true;
        }

view plaincopy to clipboardprint?
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator" ClientValidationFunction="chkddl" ControlToValidate="DropDownList1"></asp:CustomValidator> 
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator" ClientValidationFunction="chkddl" ControlToValidate="DropDownList1"></asp:CustomValidator>  

 验证textbox

function chktext(source, args){  
            if(args.Value=="")  
                args.IsValid = false;  
            else 
                args.IsValid=true;  
        } 
function chktext(source, args){
            if(args.Value=="")
                args.IsValid = false;
            else
                args.IsValid=true;
        }

view plaincopy to clipboardprint?
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator" ClientValidationFunction="chktext" ControlToValidate="TextBox1" ValidateEmptyText="True"></asp:CustomValidator>  
                  

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/gengwanshanreally/archive/2009/05/05/4152608.aspx

原创粉丝点击