title: Jquery - $(this).length of checkboxes or radio buttons is always 1
body: <pre><code>&lt;TD&gt;
  &lt;input type="text" name="name1" size="35" class="mustEnter" /&gt;
  &lt;/TD&gt;
  
  &lt;TD&gt;
  &lt;input type="radio" name="name2" value="val1" class="mustCheck"/&gt;
  &lt;input type="radio" name="name2" value="val2" class="mustCheck"/&gt;
  &lt;input type="radio" name="name2" value="val3" class="mustCheck"/&gt;
  &lt;/TD&gt;
  
  &lt;TD&gt;
  &lt;input type="checkbox" name="name3" value="valA" class="mustCheck"/&gt;
  &lt;input type="checkbox" name="name3" value="valB" class="mustCheck"/&gt;
  &lt;input type="checkbox" name="name3" value="valC" class="mustCheck"/&gt;
  &lt;/TD&gt;
  </code></pre>
  
  <p>I want to test if the a mandatory field (in this case radio and check boxes) were checked, but it does not work.</p>
  
  <p><code>each()</code> passes through the radio buttons (or check boxes) three times and <code>$(this).length</code> is always 1.  I want to avoid testing by name as the list could be long. What would be the solution?</p>
  
  <pre><code>valid = true;
  $("#studentForm input.mustEnter, #studentForm input.mustCheck").each(function() {
      if( ($(this).hasClass('mustEnter') &amp;&amp; $(this).val() != false ) 
       || ($(this).hasClass('mustCheck') &amp;&amp; $(this).length &gt; 0) ) {
      $(this).parent().removeClass("errorHighlight");
  }
  else { 
      $(this).parent().addClass('errorHighlight');
       valid = false;
  }
  </code></pre>