title: validate radio buttons for a quiz
body: <p>Need to validate radio buttons am developing a quiz page i can only validate 1 set of radio buttons any help be great below is my code. If a user hits the submit button without answering a question I want a alert message displayed saying u must answer whatever question they didnt answer. Any ideas as to why the jquery wont work thanks</p>
  
  <pre><code>&lt;!doctype html&gt;
    &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt;
  
                       &lt;script type="text/javascript"&gt;
                       $('#quizForm').on('submit', function() {
      var emptyCount = 0;
      $('li').each(function() {
          var found = false;
          $(this).find('input[type=radio]').each(function() {
              if ($(this).prop('checked')) {
                  found = true;
              }
          });
          if (!found) {
              emptyCount++;
          }
      });
      if (emptyCount &gt; 0) {
          alert('Missing checks:' + emptyCount);
          return false;
      }
      return true;
                       &lt;/script&gt;
  
  
                    &lt;form action='mail.php' method='post' id='quizForm' id='1' name='quizForm' onSubmit='form()'&gt;
      &lt;ol&gt;
          &lt;li&gt;
              &lt;h3&gt;1 x 1 =&lt;/h3&gt;
              &lt;div&gt;
                  &lt;input type='radio' name='answerOne' id='answerOne' value='A' /&gt;
                  &lt;label for='answerOneA'&gt;A)1&lt;/label&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;input type='radio' name='answerOne'  id='answerOne' value='B' /&gt;
                  &lt;label for='answerOneB'&gt;B)2&lt;/label&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;input type='radio' name='answerOne' id='answerOne' value='C' /&gt;
                  &lt;label for='answerOneC'&gt;C)3&lt;/label&gt;
              &lt;/div&gt;
          &lt;/li&gt;
          &lt;li&gt;
              &lt;h3&gt;1 x 6 =&lt;/h3&gt;
              &lt;div&gt;
                  &lt;input type='radio' name='answerTwo' id='answerTwo' value='A' /&gt;
                  &lt;label for='answerTwoA'&gt;A)5&lt;/label&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;input type='radio' name='answerTwo' id='answerTwo' value='B' /&gt;
                  &lt;label for='answerTwoB'&gt;B)6&lt;/label&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;input type='radio' name='answerTwo' id='answerTwo' value='C' /&gt;
                  &lt;label for='answerTwoC'&gt;C)4&lt;/label&gt;
              &lt;/div&gt;
          &lt;/li&gt;
          &lt;li&gt;
              &lt;h3&gt;2 x 8 =&lt;/h3&gt;
              &lt;div&gt;
                  &lt;input type='radio' name='answerThree' id='answerThree' value='A' /&gt;
                  &lt;label for='answerThreeA'&gt;A)14&lt;/label&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;input type='radio' name='answerThree' id='answerThree' value='B' /&gt;
                  &lt;label for='answerThreeB'&gt;B)12&lt;/label&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;input type='radio' name='answerThree' id='answerThree' value='C' /&gt;
                  &lt;label for='answerThreeC'&gt;C)16&lt;/label&gt;
              &lt;/div&gt;
          &lt;/li&gt;
      &lt;/ol&gt;
      &lt;input type="submit" /&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>