title: How to group checkboxes for validation in Bootstrap
body: <p>I have a simple <code>form</code> which has 2 <code>checkboxes</code>. I want to submit the form if any one of the checkbox is checked. Below code requires to check both of them. I tried grouping checkboxes by using <code>name</code> attribute but thats not sufficient, I am missing something. How can we group checkboxes for validation so that if any one is selected then form should be submited. Any suggestion would be helpful. </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;!-- Required meta tags --&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"&gt;
  
      &lt;!-- Bootstrap CSS --&gt;
      &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form class="needs-validation" novalidate&gt;
  
      &lt;div class="form-check"&gt;
        &lt;input class="form-check-input" type="checkbox" value="" id="Check1" name="select" required&gt;
        &lt;label class="form-check-label" for="Check1"&gt;Option 1&lt;/label&gt;
      &lt;/div&gt;
      &lt;div class="form-check"&gt;
        &lt;input class="form-check-input" type="checkbox" value="" id="Check2" name="select" required&gt;
        &lt;label class="form-check-label" for="Check2"&gt;Option 2&lt;/label&gt;
      &lt;/div&gt;
  
    &lt;button class="btn btn-primary" type="submit"&gt;Submit&lt;/button&gt;
  
  &lt;/form&gt;
  
  &lt;script&gt;
  
  (function() {
    'use strict';
    window.addEventListener('load', function() {
  
      var forms = document.getElementsByClassName('needs-validation');
  
      var validation = Array.prototype.filter.call(forms, function(form) {
        form.addEventListener('submit', function(event) {
          if (form.checkValidity() === false) {
            event.preventDefault();
            event.stopPropagation();
          }
          form.classList.add('was-validated');
        }, false);
      });
    }, false);
  })();
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>