title: How to tell if a radio button is left unchecked with Javascript/JQuery
body: <p>I am creating a quiz/survey form with jQuery and javascript and I am having some trouble with the question validation.</p>
  
  <p>The way the quiz/survey creation works is a series of show/hides display relevant form fields. The user fills out one set of fields for the first question and then they are asked if they would like to add another question to their quiz/survey and the next set of form fields is displayed. </p>
  
  <p>I am struggling because instead of having a massive validation when the user has completed all of their possible form fields I am running a validation script at the end of each question with the associated form field IDs and values being passed into the script upon the user completing that question. This script is below, but some key areas of the script are based upon whether radio buttons have been checked. For instance if the user has left the question text area empty they are alerted to fill in question text, or if they select a true/false answer or multiple choice answer, they are supposed to determine which is the correct answer based upon a radio button list. Here is the entire validation code:</p>
  
  <pre><code>var questionValidate = function(qTextID, qAnswerType, TFID, MCID, MCText1, MCText2, MCText3, MCText4, VisRef, Youtube, Vimeo, ImgID) {
      // alert(qTextID, qAnswerType, TFID, MCID, MCText1, MCText2, MCText3, MCText4, VisRef, Youtube, Vimeo, ImgID);
      if (jQuery('select[name="CAT_Custom_14"]').val() == 'Quiz') {
          if (jQuery(qTextID).val() == "") {
              var qText = true;
              alert('Question Text field is blank!');
          };
           if (jQuery(qAnswerType).val() == " ") {
              var answertype = true;
              alert("There's no answer selected.");
          } else if (jQuery(qAnswerType).val() == 'True/False') {
              if (jQuery(TFID).attr("checked") == true) {
                  var tfanswer = true;
                  var mcanswer = false;
                  alert('True False is selected');
              } else if (jQuery(TFID).attr("checked") == false) {
                  alert('True False is not selected.');
              };
          } else if (jQuery(MCID).attr("checked") != 'checked' ) {
              var mcanswer = true;
              var tfanswer = false;
              alert('The correct Multiple Choice Answer is not selected');
              if (jQuery(MCText1).val() == "" || jQuery(MCText2).val() == "" || jQuery(MCText3).val() == "" || jQuery(MCText4).val() == "") {
                  var mcTextfields = true;
                  alert("There are Multiple Choice Fields that you have left blank.");
              } else {
                  mcTextfields = false;
              };
  
          };
          if (jQuery(VisRef).val() != " ") {
              if (jQuery(VisRef).val() == "Youtube Video" &amp;&amp; jQuery(Youtube).val() == "") {
                  youtubeVal = true;
                  alert('Please enter your Youtube Video code.');
              } else if (jQuery(VisRef).val() == "Vimeo Video" &amp;&amp; jQuery(Vimeo).val() == "") {
                  vimeoVal = true;
                  alert('Please enter your Vimeo Video code.');
              } else {
                  validateImage(ImgID);
              };
              } else {
                  youtubeVal = false;
                  vimeoVal = false;
                  tempImgCheck = false;
              }
          };
      };
  </code></pre>
  
  <p>I have run into a way to tell whether the radio button is checked, however it does not appear to be working with my script the way that I want it to. If you look at this area of the code you should be able to see that it first determines the answer type (true/false or multiple choice) and then if the correct answer is not selected the user should be alerted. So if they do not select the 'true', 'false', 'a', 'b', 'c', or 'd' radio button the validation should alert them to select it. </p>
  
  <p>If there are any other ways to check if the correct radio buttons are selected I would appreciate anyone's help in figuring this out. </p>
  
  <p>Thank you so much!</p>