title: Radio button validation through JavaScript
body: <p>I have the following form:</p>
  
  <pre><code>&lt;form name="survey1" action="add5up.php" method="post" onsubmit="return validateForm()"&gt;
  &lt;div id="question"&gt;Q1) My programme meets my expectations&lt;/div&gt;&lt;br /&gt;
  Always&lt;INPUT  TYPE = 'Radio' Name ='q1'  value= 'a'&gt; 
  Usually&lt;INPUT  TYPE = 'Radio' Name ='q1' value= 'b'&gt; 
  Rarely&lt;INPUT  TYPE = 'Radio' Name ='q1' value= 'c'&gt; 
  Never&lt;INPUT  TYPE = 'Radio' Name ='q1' value= 'd'&gt; 
  &lt;input type="submit" value="addData" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I am trying to validate whether a <code>Radio</code> button has been selected.</p>
  
  <p>The code I am using:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function validateForm()
  {
  if( document.forms["survey1"]["q1"].checked)
  {
      return true;
  }
  
  else
  {
      alert('Please answer all questions');
      return false;
  }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>This is not working. Any ideas?</p>