title: JQuery Validating Multiple Checkbox Groups
body: <p>I have the following two checkbox groups:</p>
  
  <pre><code>&lt;fieldset class="CbxGroup"&gt;
    &lt;legend&gt;Checkbox Group (required)&lt;/legend&gt;
    &lt;label&gt;&lt;input type="checkbox" name="cbxGroup1[]" value="one" id="cbxGroup1_0"&gt;One &lt;/label&gt;
    &lt;br&gt;
    &lt;label&gt;&lt;input type="checkbox" name="cbxGroup1[]" value="two" id="cbxGroup1_1"&gt;Two &lt;/label&gt;
    &lt;br&gt;
    &lt;label&gt;&lt;input type="checkbox" name="cbxGroup1[]" value="three" id="cbxGroup1_2"&gt;Three&lt;/label&gt;
    &lt;br&gt;
    &lt;label&gt;&lt;input type="checkbox" name="cbxGroup1[]" value="four" id="cbxGroup1_3"&gt;Four &lt;/label&gt;
    &lt;br&gt;
    &lt;label&gt;&lt;input type="checkbox" name="cbxGroup1[]" value="five" id="cbxGroup1_4"&gt;Five &lt;/label&gt;
    &lt;br&gt;
  &lt;/fieldset&gt;
  
  &lt;fieldset class="CbxGroup"&gt;
  &lt;legend&gt;Checkbox Group (required)&lt;/legend&gt;
    &lt;label&gt;&lt;input type="checkbox" name="cbxGroup2[]" value="one" id="cbxGroup2_0"&gt;One &lt;/label&gt;
    &lt;br&gt;
    &lt;label&gt;&lt;input type="checkbox" name="cbxGroup2[]" value="two" id="cbxGroup2_1"&gt;Two &lt;/label&gt;
    &lt;br&gt;
    &lt;label&gt;&lt;input type="checkbox" name="cbxGroup2[]" value="three" id="cbxGroup2_2"&gt;Three&lt;/label&gt;
    &lt;br&gt;
    &lt;label&gt;&lt;input type="checkbox" name="cbxGroup2[]" value="four" id="cbxGroup2_3"&gt;Four &lt;/label&gt;
    &lt;br&gt;
    &lt;label&gt;&lt;input type="checkbox" name="cbxGroup2[]" value="five" id="cbxGroup_4"&gt;Five &lt;/label&gt;
    &lt;br&gt;
  &lt;/fieldset&gt;
  </code></pre>
  
  <p>Each checkbox-group (fieldset) is tagged with the same class name. I'd like to validate each GROUP so at least one checkbox is selected in EACH group.</p>
  
  <p>I have the following JQuery but it sees them as a single group rather than two separate ones. Can you help me tweak this code so it validates each group separately?</p>
  
  <pre><code>$('.CbxGroup').each(function() {
          if($('.CbxGroup input[type=checkbox]:checked').length == 0) {
              alert('not selected!');
          }
          else{
              alert('selected!');
          }
      });
  </code></pre>
  
  <p>This way I can add any number of checkbox-groups and have them all validated rather writing separate chunks of code for each group.</p>
  
  <p>Thank you!</p>