title: How to validate present checkboxlist in a asp.net page
body: <p>I have a asp.net page which has checkboxlists and radiobuttonlist. The problem is not all the checkbox list and radiobutton list are visible all the time. some are hidden some are displayed depending on the logic. At the end i have a button to submit that will do something at the server side. How can i do required field validation the all controls using javascript. i tried asp.net validation controls. What happens is it gives me error when no value is selected and right after when i provide values then it doesn't do anything and doesn't gives any error. autopost back is enabled in each control becoz i am capturing the value and storing it in server side. i have a javascript code but it works for only one control at a time. 
  How can i use it for all the controls present in the curernt page.</p>
  
  <pre><code>    &lt;script type = "text/javascript"&gt;
       var atLeast = 1
      function Validate()
      {
       var CHK = document.getElementById("&lt;%=CheckBoxList1.ClientID%&gt;");
       var checkbox = CHK.getElementsByTagName("input");
       var counter=0;
      for (var i=0;i&lt;checkbox.length;i++)
      {
        if (checkbox[i].checked)
        {
          counter++;
       }
    }
    if(atLeast&gt;counter)
    {
        alert("Please select atleast " + atLeast +  " item(s)");
      return false;
   }
    return true;
     }
    &lt;/script&gt;
  </code></pre>