Check at least one checkbox is selected in CheckBoxList using ASP.Net Validators

Filed in Uncategorized Leave a comment

I found a very good article to check that at least one chekbox is selected in a checkboxlist control. Works exactly like required field validator. (check answer from user yasserzaid)

<script type=”text/javascript”>

function ValidateRolesSelection(source, args)


//if your checkboxlist control is on simple page

var chkListModules = document.getElementById(‘<%= RolesCheckBoxList.ClientID %>’);

//if your checkboxlist control is inside some user control for e.g in CreateUserWizard

//var chkListModules = document.getElementById(‘<%= (CreateUserWizard1.WizardSteps[0].Controls[0].FindControl(“RolesCheckBoxList”) as CheckBoxList).ClientID %>’);

var chkListinputs = chkListModules.getElementsByTagName(“input”);

for (var i = 0; i < chkListinputs.length; i++)


if (chkListinputs[i].checked)


args.IsValid = true;




args.IsValid = false;