title: make input field required whose correspond checkbox is checked
body: <p>I am making a form where I am selecting only one checkbox from group of checkbox.
  I want to make input field required whose corresponding checkbox are checked.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    $('.check').click(function() {
      let name = $(this).attr("name")
      if ($(this).prop('checked')) {
        $('.check[name="' + name + '"]').prop('required', false)
      } else {
        $('.check[name="' + name + '"]').prop('required', true)
      }
      $('.check[name="' + name + '"]').not(this).prop('checked', false)
    });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;input type="checkbox" id="OVD" name="OVD" class="check" required&gt;
      &lt;h5&gt;A. Passport Number&lt;/h5&gt;
      &lt;input type="text"&gt;&lt;br&gt;
      &lt;input type="checkbox" id="OVD" name="OVD" class="check" required&gt;
      &lt;h5&gt;B. Voter ID Card&lt;/h5&gt;
      &lt;input type="text"&gt;&lt;br&gt;
      &lt;input type="checkbox" id="OVD" name="OVD" class="check" required&gt;
      &lt;h5&gt;C. Driving Licence&lt;/h5&gt;
      &lt;input type="text"&gt;&lt;br&gt;
      &lt;input type="checkbox" id="OVD" name="OVD" class="check" required&gt;
      &lt;h5&gt;D. NREGA Job Card&lt;/h5&gt;
      &lt;input type="text"&gt;&lt;br&gt;
      &lt;input type="checkbox" id="OVD" name="OVD" class="check" required&gt;
      &lt;h5 class="d-inline"&gt;E. National Population Register Letter&lt;/h5&gt;
      &lt;input type="text"&gt;&lt;br&gt;
      &lt;input type="checkbox" id="OVD" name="OVD" class="check" required&gt;
      &lt;h5 class="d-inline"&gt;F. Proof of Possession on Aadhaar&lt;/h5&gt;
      &lt;input type="text"&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>here I can only select one checkbox and make its corresponding text field required.
  I want if I select nth checkbox then nth input field will mandatory to be filled.</p>