troubleshooting Question

How to implement a checkboxlist validator checking for checbox checked

Avatar of TechIsaac
TechIsaacFlag for United States of America asked on
ASP.NETVisual Basic.NET* Advanced Custom Fields
2 Comments1 Solution78 ViewsLast Modified:
I'm trying to include a custom checkboxlist validation to produce an error message if none of the boxes
have been checked.  I've tried to incorporate into my code but to this date and time nothing
seems to want to work.  My most recent try is seen below which is a snippet from my code.

I need direction to something that will work.

<td width="35px" class="pCheck" >
                                        <asp:CheckBoxList ID="cblItems" runat="server" enabled="true" AutoPostBack="true" CellPadding="0"
                                            CellSpacing="0" class="cblItems" RepeatColumns="2" RepeatDirection="Vertical"
                                            RepeatLayout="Table" value="item_name" CausesValidation="true">
                                        <!-- Isaac -->
                                        <asp:CustomValidator ID="Custom1"
                                          ErrorMessage="You must select a service or item">

<script type="text/javascript">
    function CheckBoxValidation(oSrouce, args) {
        var myCheckBox = document.getElementById("cblItems");

        for (i = 0; i < cblItems.length; i++) {
                if (myCheckBox.checked) {

                    args.IsValid = true;

                    args.IsValid = false;


When I run this code, the app shows the error message when I check a box, but if I donot check a boxx and submit, the app continues
with recognizing the error - backwards.

I am running out of time to complete this task.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros