title: How to make this form validation script loop through the whole form section before returning?
body: <p>I am developing a <a href="http://www.gezondezorg.org/upt-schaal-tryout.php" rel="nofollow">patient satisfaction questionnaire</a>. I have a form validation script that should check whether one or more items in the A sub-section has been given a score, if on the A main question certain radios are checked. It looks like this at the moment: </p>
  
  <pre><code>function countRadiosChecked(chdRds) { 
      var cnt = -1;
      for (i=chdRds.length-1; i&gt;-1; i--) {
          if (chdRds[i].checked)
          {cnt=i; i=-1;}
      }
      if (cnt &gt; -1) return chdRds[cnt].value;
      else return null; /* = the number, not the value of the radio buttons */
  }
  
  
  function checkASection() {
  if ((upssForm.A[0].checked == true) || (upssForm.A[1].checked == true) || (upssForm.A[2].checked == true) || (upssForm.A[4].checked == true)) {
      var itemsANamesArray = ['A1a','A1b','A1c','A1d','A1e','A1f','A1g','A2a','A2b','A2c','A2d','A2e','A2f','A2g','A2h','A2i','A2j','A2k','A2l','A2m','A2n','A2o','A2p','A2q','A2r'];
      var thatAName = null;
      var itemsANamesArrayCount = itemsANamesArray.length;
      for (i=0; i&lt;itemsANamesArrayCount; i++) {
          thatAName = itemsANamesArray[i];
          var thatANameGroup = upssForm.elements[thatAName];
          var nrOfRadiosChecked = countRadiosChecked(thatANameGroup);
              if (nrOfRadiosChecked == null)
          {
              alert('No item in the A sub-section has been given a score');
              return;
          }
          return;
      }
  }
  }
  </code></pre>
  
  <p>But the script already gives an alert if on the first item no score has been given, while it should loop through the whole array before alerting, if necessary. How do I that?  </p>