验证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">用户权限: </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>
<!--
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">用户权限: </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>