title: check atleast one checkbox is checked on form submission
body: <p>I have a form that consists of checkbox fields, now on form submission we should check whether atleast one checkbox is checked</p>
  
  <p><strong>html code</strong></p>
  
  <pre><code>&lt;form id="form_check" class="form" action="/path/to/some/url" method="POST"&gt;
    {% for field in fields %}
       &lt;div class="check_fields"&gt;  
           &lt;input class="select-unselect" type="checkbox" name="invite" value=""&gt;
            {{field}}
       &lt;/div&gt;
    {% endfor %} 
       &lt;input type="submit" class="btn btn-primary" value="Submit" onsubmit="atleast_onecheckbox()"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>javascript code</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function atleast_onecheckbox()
              {
               var value = $("[name=invite]:checked").length &gt; 0);
                   alert(value) ;      
                   if (!value)
                        {
                      alert("Please.....");
                         }
              }   
  &lt;/script&gt;    
  </code></pre>
  
  <p>So when i clicked on the submit button, the form is redirecting to the url mentioned in the <code>action</code>, but its not even hitting the javascript function <code>atleast_onecheckbox()</code> </p>
  
  <p>what wrong in the above code, can anyone please make the above code work  ?</p>