title: check for empty radio input
body: <p>I want to check if the user selects a radio button. I have coded this:</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form action="myServlet" method="post"&gt;
          &lt;input type="radio" id="rating-input-1-5" name="ratingInput1" value="5"&gt;
          &lt;input type="radio" id="rating-input-1-4" name="ratingInput1" value="4"&gt;
          &lt;input type="radio" id="rating-input-1-3" name="ratingInput1" value="4"&gt;        
          //etc
  &lt;button type="submit" class="myButton" onclick="sendSuccess()"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>   function sendSuccess(){
  
          var len = document.formRate.ratingInput1.length;
          var flag;
  
          for(i=0; i&lt;len; i++){
              if (document.formRate.ratingInput[i].checked){
                  flag = true;
              }
              else{
                  flag = false;
                  break;
              }   
          }
  
          if(flag === false){
              console.log('noooooo');
              return false;
          }else{
              console.log('yesssss');
          }
      }
  </code></pre>
  
  <p>But its not working.</p>