title: Validation of radio buttons with Javascript
body: <p>I've combed a ton of the pages on here, and still am incapable to get my explicit validator to work. Basically, when the submit button is clicked, I want the script to verify a radio is checked, if one is checked to do nothing.  If one isn't checked I want it to post an alert message.</p>
  
  <p>roughly my html looks like:</p>
  
  <pre><code>&lt;form id="myForm" onsubmit = "check()"&gt;
  &lt;input type = "radio" name = "c" id = "1" value = "1" /&gt;
  &lt;input type = "radio" name = "c" id = "2" value = "2" /&gt;
  &lt;input type = "radio" name = "c" id = "3" value = "3" /&gt;
  
  &lt;input type = "submit" value = "Submit" /&gt;
  </code></pre>
  
  <hr>
  
  <p>my JS page looks like:</p>
  
  <pre><code>function check() {
      var r = document.getElementsByName("c")
      var c = 0
  
      for(var i=0; i &lt; r.length; i++){
         if(c[i].checked) {
            c = i; }
      }
  
      alert("please select radio");
  }
  </code></pre>