Required field validator for CheckBoxList
<asp:CheckBoxList ID="chkDepartments" runat="server" RepeatDirection="Horizontal"></asp:CheckBoxList>
<asp:CustomValidator runat="server" ID="chkT"
ClientValidationFunction="ValidateDepartments"
ErrorMessage="Please select atleast one
Department" ValidationGroup="k" ForeColor="Red"></asp:CustomValidator>
<script type="text/javascript">
function ValidateDepartments(source, args) {
var chkListModules = document.getElementById('<%= chkDepartments.ClientID %>');
var chkListinputs = chkListModules.getElementsByTagName("input");
for (var i = 0; i < chkListinputs.length; i++) {
if (chkListinputs[i].checked) {
args.IsValid = true;
return;
}
}
args.IsValid = false;
}
</script>
Hope this will helps you................
Hope this will helps you................
Comments
Post a Comment