zoukankan      html  css  js  c++  java
  • 【记录】自定义服务器验证控件

     <asp:CheckBoxList ID="ck1" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Value="2">街道办用户</asp:ListItem>
                            <asp:ListItem Value="3">社区用户</asp:ListItem>
                            <asp:ListItem Value="4">培训机构用户</asp:ListItem>
                            <asp:ListItem Value="5">学员用户</asp:ListItem>
                        </asp:CheckBoxList>
                        <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ClientValidate"
                            Display="Dynamic" ErrorMessage="请至少选择一个"></asp:CustomValidator>
    

     自定义验证控件

    function  ClientValidate(sender, args)
            {
                var flag = false;
                var radioList=document.getElementById("ck1"); 
                var inarr = radioList.getElementsByTagName('input'); 
                for (var i=0; i<inarr.length; i++)
                {
                    if(inarr[i].type=="checkbox")
                     {
                        if(inarr[i].checked==true)    
                         {
                             flag = true;
                         }
                      }
                 }
                 if (flag)
                 {
                    args.IsValid = true;
                 }
                 else
                 {
                    args.IsValid = false;
                 }
            }
    
    从小就很拽****【越努力越幸运】
  • 相关阅读:
    TeX中的引号
    竖式问题
    蛇形填数
    开灯问题
    排列
    分数化小数
    子序列的和
    cookie
    post请求
    get请求
  • 原文地址:https://www.cnblogs.com/net-nai/p/Check.html
Copyright © 2011-2022 走看看