验证CheckBoxList至少要有一项选中

<script language="javascript" type="text/javascript"> 
        
<!--
        
function  ClientValidate(sender, args)
        
{
            
var flag = false;
            
var  inarr=form1.all.tags("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;
             }

        }

        
-->
</script>
<tr>
    
<td align="right" bgcolor="#FFFFFF">用户权限:&nbsp;</td>
    
<td bgcolor="#FFFFFF"><asp:CheckBoxList ID="cblrighgs" runat="server" RepeatLayout="Flow" RepeatColumns="5">
        
</asp:CheckBoxList>
        
<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ClientValidate"
            Display
="Dynamic" ErrorMessage="请选择用户权限"></asp:CustomValidator></td>
  
</tr>

posted on 2007-04-27 11:28  ★金★  阅读(2003)  评论(4编辑  收藏  举报

导航