title: Need help validating radio buttons
body: <p>Trying to get my final project ready on time (for once) but I cannot seem to get the radio-button group to validate when submitting the form. I have everything else working, and validation is so-so, however, the radio group is being stubborn. I've tried different ways such as removing the variable and pointing directly to the 'group1' but nothing has worked. Any help would be greatly appreciated. </p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      function ValidateContactForm()
      {
      var name = document.ContactForm.Name;
      var email = document.ContactForm.Email;
      var phone = document.ContactForm.areaCode;
      var what = document.ContactForm.Subject;
      var comment = document.ContactForm.Comment;
      var btn = document.ContactForm.group1;
  
      if (name.value == "")
      {
          window.alert("Please enter your name.");
          name.focus();
          return false;
      }
  
      if (email.value == "")
      {
          window.alert("Please enter a valid e-mail address.");
          email.focus();
          return false;
      }
      if (email.value.indexOf("@", 0) &lt; 0)
      {
          window.alert("Please enter a valid e-mail address.");
          email.focus();
          return false;
      }
      if (email.value.indexOf(".", 0) &lt; 0)
      {
          window.alert("Please enter a valid e-mail address.");
          email.focus();
          return false;
      }
  
      if  (btn.value &gt; 0) {
          window.alert("Please choose method of contact.");
          btn.focus();
          return false;
          }
  
      if (phone.value == "")
      {
          window.alert("Please enter your telephone number.");
          phone.focus();
          return false;
      }
  
      if (what.selectedIndex &lt; 1)
      {
          alert("Please tell us how we can help you.");
          what.focus();
          return false;
      }
  
      if (comment.value == "")
      {
          window.alert("Please provide a detailed description or comment.");
          comment.focus();
      return false;
              }
      }
      function validateFixedLengthNumericField(numericField, len){
  
      if (len != numericField.value.length){
          numericField.focus();   
          alert('Field must contain exactly '+len+' numbers.');
      }
      }
  
      function validateNextField(numericField, len, nextField){
  
      if (len == numericField.value.length){
          nextField.focus();
      }
      }
      &lt;/script&gt;
  
      &lt;form method="post" onSubmit="return ValidateContactForm();" name="ContactForm"&gt;
    &lt;div align="center"&gt;
        &lt;table border="2"&gt;
      &lt;tr&gt;
        &lt;td valign="top"&gt;&lt;h3 align="left"&gt;Contact Information&lt;/h3&gt;
      &lt;p align="left"&gt;Name:&lt;br /&gt; &lt;input type="text" size="65" name="Name"&gt;&lt;/p&gt;
      &lt;p align="left"&gt;E-mail Address:&lt;br /&gt;&lt;input type="text" size="65" name="Email"&gt;&lt;/p&gt;
      &lt;p align="left"&gt;Telephone:&lt;br /&gt; 
        &lt;div class="Telephone" style="float:left;"&gt;
              (&lt;input name="areaCode" id="areaCode"  type="text"  maxlength="3"
                  onkeyup="validateNextField(this,3,phonePrefix);" 
                  onblur="validateFixedLengthNumericField(this,3);"  
                  style="font-size:11px; width:20px;"  title="Area Code" autocomplete="off"&gt;) 
              &lt;input name="phonePrefix" id="phonePrefix" type="text" 
                  onkeyup="validateNextField(this,3,phoneSuffix);" 
                  onblur="validateFixedLengthNumericField(this,3);"  
                  style="font-size:11px; width:20px;" maxlength="3"  title="Phone Prefix"  autocomplete="off"&gt;-
              &lt;input name="phoneSuffix" id="phoneSuffix" type="text"  maxlength="4" 
                  onkeyup="validateNextField(this,3,phoneExtension);" 
                  onblur="validateFixedLengthNumericField(this,4);"  
                  style="font-size:11px; width:25px;" title="Phone Suffix"  autocomplete="off"&gt;&lt;/p&gt;
      &lt;/div&gt;
        &lt;p align="left"&gt;&amp;nbsp;&lt;/p&gt;
        &lt;p align="left"&gt;&lt;strong&gt;Would you like to sign up for one of our mailings?&lt;/strong&gt;  &lt;br /&gt;
        &lt;/p&gt;
      &lt;div align="left"&gt;
        &lt;input type="checkbox" name="option" value="newsletter" /&gt;
        Newsletters&lt;br /&gt;
        &lt;input type="checkbox" name="option" value="events" /&gt;
        Events&lt;br /&gt;
        &lt;input type="checkbox" name="option" value="grando" /&gt;
        Grand Openings&lt;br /&gt;
        &lt;input type="checkbox" name="option" value="coupon" /&gt;
        Coupons&lt;br /&gt;
        &lt;input type="checkbox" name="option" value="other" /&gt;
        Other&lt;/div&gt;
      &lt;p align="left"&gt;&lt;strong&gt;How do you perfer us to contact you&lt;/strong&gt;&lt;br /&gt;
      &lt;/p&gt;
      &lt;div align="left"&gt;
        &lt;input type="radio" name="group1" id="r1" value="1" /&gt;
        Phone
        &lt;br /&gt;
      &lt;input type="radio" name="group1" id="r2" value="2" /&gt;
      Email&lt;br /&gt;
      &lt;input type="radio" name="group1" id="r3" value="3" /&gt;
      Snail Mail
      &lt;/div&gt;
      &lt;p align="left"&gt;What can we help you with?
        &lt;select type="text" value="" name="Subject"&gt;
              &lt;option&gt;  &lt;/option&gt;
              &lt;option&gt;Customer Service&lt;/option&gt;
              &lt;option&gt;Question&lt;/option&gt;
              &lt;option&gt;Comment&lt;/option&gt;
              &lt;option&gt;Complaint&lt;/option&gt;
              &lt;option&gt;Other&lt;/option&gt;
      &lt;/select&gt;&lt;/p&gt;
      &lt;p align="left"&gt;Comments:&lt;/p&gt;
      &lt;p align="center"&gt;
        &lt;textarea cols="55" rows="10" name="Comment"&gt;&lt;/textarea&gt;
      &lt;/p&gt;
      &lt;p align="center"&gt;&lt;input type="submit" value="Send" name="submit"&gt;&lt;input type="reset"      value="Reset" name="reset"&gt;    
        &lt;/form&gt;
  </code></pre>