title: jQuery Post with radio button check verification
body: <p>I have a page that uses jQuery post to submit a form and return the data within a div tag in the same page.  then the form is still accessible so that multiple questions can be asked to the user and information will be elicited from the data base.</p>
  
  <p>On the first time around if the user tries to submit the form without selecting a radio button they get an alert box that says they must make a selection.  However after the first time through the user can submit the form without making a selection.  </p>
  
  <p>The radio buttons are maintaining their set value.  Any ideas on how I can use this format and make sure that with each successive form submission a radio button is selected?</p>
  
  <p>Here is the first page test.php</p>
  
  <pre><code>    &lt;!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
      &lt;html&gt;
      &lt;head&gt;
  
      &lt;title&gt;test jQuery post&lt;/title&gt;
      &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript"&gt;
      //&lt;![CDATA[
      jQuery.noConflict ();
  
      jQuery(document).ready(function(){
        initializeForm();
        });
  
      function initializeForm() {
        jQuery("#university").validate({
  
            debug: false,
            submitHandler: function(form) {
  
  
            var validationTypes = jQuery("#validationTypes");
            var valid = false;
  
  
                          if (validationTypes.val()== 'radio')
                              {
                                 for(i=0; i&lt;university.radio.length; i++) if(university.radio[i].checked) {valid=true;}
  
                                  if (valid == false)
                                        {
                                            alert ( "Please pick an answer before trying to Submit this form." );
                                            return false;
                                        }
  
                              }
  
  
                jQuery.post('post.php',
                    jQuery("#university").serialize(),
                    function(data) {
                        jQuery('#box').html(data);
                        initializeForm();
  
                    });
  
            }
  
        });
        }
  
  
  
      // ]]&gt;
      &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;div id="box"&gt;&lt;? include('post.php') ?&gt;&lt;/div&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>Here is the second page post.php</p>
  
  <pre><code>&lt;?
  
  $radio = (isset($_POST['radio'])? $_POST['radio']: 0);
      switch ($radio)
          {
            default:
            echo 'pick a number&lt;br /&gt;&lt;br /&gt;';
            break;
            case '1':
            echo 'you pick one&lt;br /&gt;&lt;br /&gt;Pick Again&lt;br /&gt;&lt;br /&gt;';
            break;
            case '2':
            echo 'you pick two&lt;br /&gt;&lt;br /&gt;Pick Again&lt;br /&gt;&lt;br /&gt;';
            break;
            case '3':
            echo 'you pick three&lt;br /&gt;&lt;br /&gt;Pick Again&lt;br /&gt;&lt;br /&gt;';
            break;
          }
  ?&gt;
  &lt;form action="" method="POST" id="university" name="university"&gt;
  &lt;input type="radio" name="radio" value="1" /&gt; 1&amp;nbsp;&amp;nbsp;
  &lt;input type="radio" name="radio" value="2" /&gt; 2&amp;nbsp;&amp;nbsp;
  &lt;input type="radio" name="radio" value="3" /&gt; 3&amp;nbsp;&amp;nbsp;
  &lt;input type="hidden" name="validationTypes" id="validationTypes" value="radio"&gt;
  &lt;input type="submit" name="submit" value="submit" /&gt;&lt;/form&gt;
  </code></pre>