title: Checkbox validation in Javascript
body: <p>Hello All I am having 2 groups of checkboxes which are been generated dynamically through java depending the code generator tool generate the following HTML</p>
  
  <p>I am having the following JS to validate that atleast one of the checkbox is been selected from the each row which is not working I know if we give the same name it would work , just wanted to check if there is any work around for this with the name been changed</p>
  
  <p>I cannot use JQUERY due to certain limitations</p>
  
  <pre><code>function validate()
  {
        var e = document.form.elements;
      for ( var elem, i = 0; ( elem = e[i] ); i++ )
      {
           if (  elem.type == 'checkbox' )
          {
              if (!checkCheckBox (form, elem))
              {
                  alert('Please check atleast one checkbox.');
                  return false;
              } 
          } 
       } 
      document.form.submit();
      return true;
  } 
  
   function checkCheckBox (form, elem)
  {
       var check= form.elements[elem.name];
       var flag = false;
       for (var i=0; i &lt;check.length; i++)
      {
          //alert(" radios[i].checked "+elem[i].checked);
          if (check[i].checked)
          {
               flag = true;
               break;
          }
      }
  }
  
  
  
  
  
      &lt;form name="form"&gt; 
  &lt;table&gt;
   &lt;tr bgcolor='lightgray' width='100%' colspan='3'&gt;&lt;td&gt;KS3 QCheckbox 1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
  &lt;input type="checkbox" name="form[checkbox][KS31][KS31 1][]" id="COption 1" value="Option 1" /&gt; 
  &lt;input type="checkbox" name="form[checkbox][KS31][KS32 1][]" id="COption 2" value="Option 2" /&gt; 
  &lt;input type="checkbox" name="form[checkbox][KS31][KS33 1][]" id="COption 3" value="Option 3" /&gt; 
  
  &lt;tr bgcolor='lightgray' width='100%' colspan='3'&gt;&lt;td&gt;KS3 QCheckbox 2&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
  &lt;input type="checkbox" name="form[checkbox][KS32][KS31 2][]" id="COption 1" value="Option 1" /&gt; 
  &lt;input type="checkbox" name="form[checkbox][KS32][KS32 2][]" id="COption 2" value="Option 2" /&gt; 
  &lt;input type="checkbox" name="form[checkbox][KS32][KS33 2][]" id="COption 3" value="Option 3" /&gt; 
  
  &lt;input type="submit" onClick="validate()"&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>