title: How to validate radio button using javascript
body: <p>Need to validate a radio button input, i.e. when submit button is pressed and no radio buttons have been selected, it alerts the user saying 'please select a check box', and if a radio button has been selected then simply submit the form, needs no alert.</p>
  <p>Can only use HTML CSS and JavaScript for this, I know it's 1000 times easier in jquery but sadly I can't use that.</p>
  <p>And I know my HTML isn't valid, but unless it directly affects my current problem then I'll handle it later.</p>
  <pre><code>&lt;form name=&quot;form1&quot; action=&quot;#&quot; onsubmit=&quot;return validateForm()&quot; method=&quot;post&quot;&gt; 
          
      First time visitor?:&lt;br/&gt;
              &lt;label for=&quot;s1&quot;&gt;Yes&lt;/label&gt;
              &lt;input type=&quot;radio&quot; id=&quot;1&quot; name=&quot;yesno&quot; value=&quot;1&quot;/&gt;
              &lt;br/&gt;
              &lt;label for=&quot;s2&quot;&gt;No&lt;/label&gt;
              &lt;input type=&quot;radio&quot; id=&quot;1&quot; name=&quot;yesno&quot; value=&quot;2&quot;/&gt;
              
              &lt;br/&gt;       
      
      &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;&lt;br/&gt;
      &lt;/form&gt;
  </code></pre>
  <p>Any pointers are greatly appreciated, thanks.</p>