title: Verify if checkbox checked property is not empty using JavaScript
body: <p>I want to verify the checkboxes checked property. If any of them is not checked, display this sentence in span: "you should select one of them" and when I choose one of them, the message must disappear.</p>
  
  <pre><code>&lt;form  method="get"action="#" onsubmit="return vali();"&gt;
      &lt;span id="textspan" style="color:red"&gt;&lt;/span&gt;
      &lt;input type="checkbox" class='gender' id="male"&gt;male
      &lt;input type="checkbox" class='gender' id="female"&gt;female
      &lt;input type="submit" class="validate" value="send" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>function vali() {
      var bool = true;
  
      var checkedCount = $('input[class="gender"]:checked').length;
      if (checkedCount == 0) {
          $("#textspan").html('select one of them');
          bool = false;
      }
      if(checkedCount &gt;= 1) 
      {
          $("#textspan").html('');
          bool = true;
      }
  
      return bool;    
  }
  </code></pre>