CheckBoxList必选验证【转】

<script language="javascript" type="text/javascript">
function checkIssueType(source,args) {
var chkListaTipoModificaciones= document.getElementById ('<%= checkFriendList.ClientID %>');
var chkLista= chkListaTipoModificaciones.getElementsByTagName("input");
for(var i=0;i<chkLista.length;i++)
{
if(chkLista[i].checked)
{
args.IsValid
= true;
return;
}
}
args.IsValid
= false;
}
</script>
 
<div style="width: 100%; height: 190px; overflow: auto;">
<asp:CheckBoxList ID="checkFriendList" RepeatColumns="2" runat="server">
</asp:CheckBoxList>
<asp:CustomValidator ID="CustomValidator2" runat="server" ErrorMessage="不能为空" ClientValidationFunction="checkIssueType"
ValidationGroup
="CreatGroup">
</asp:CustomValidator>
</div>

posted @ 2011-08-05 17:47  Endif.ck  Views(336)  Comments(0)    收藏  举报