validation of forms with rows

validation of forms with rows

Hi, I'm a newbie in javascript, please forgive me if this is plain and simple. I followed some tutorials on 
validation and got it al working for a simple form using: 

and my own validation file :

    <script src="validation.js"></script>

I can set if a field is required or has to be an email... But my form is a little bit more complex

I have a form which consists of multiple rows with the same data (different projectlines are shown for which tasks have to be created in the planning in this form). The html mockup of the page is : 

  1.             <form id="task-form">
  2.                 <div class="form-group row task" id="1">
  3.                     <div class="col col-sm-1">
  4.                         <input type="checkbox" class="form-control form-control-sm checkbox" name="makeTask">
  5.                     </div>
  6.                     <div class="col col-sm-2">
  7.                         <input type="text" class="form-control form-control-sm deadline" name="deadline" >
  8.                     </div>
  9.                     <div class="col col-sm-2">
  10.                         <input type="text" class="form-control form-control-sm" name="collaborator">
  11.                     </div>
  12.                     <div class="col col-sm-3">
  13.                         <input type="text" class="form-control form-control-sm" >
  14.                     </div>
  15.                     <div class="col col-sm-1">
  16.                         <input type="time" class="form-control form-control-sm" >
  17.                     </div>
  18.                     <div class="col col-sm-3">
  19.                         project line name
  20.                     </div>                    
  21.                 </div> 
  22.                 <div class="form-group row task" id="12">
  23.                     <div class="col col-sm-1">
  24.                         <input type="checkbox" class="form-control form-control-sm checkbox" name="makeTask">
  25.                     </div>
  26.                     <div class="col col-sm-2">
  27.                         <input type="text" class="form-control form-control-sm" name="deadline" >
  28.                     </div>
  29.                     <div class="col col-sm-2">
  30.                         <input type="text" class="form-control form-control-sm" name="collaborator">
  31.                     </div>
  32.                     <div class="col col-sm-3">
  33.                         <input type="text" class="form-control form-control-sm" >
  34.                     </div>
  35.                     <div class="col col-sm-1">
  36.                         <input type="time" class="form-control form-control-sm" >
  37.                     </div>
  38.                     <div class="col col-sm-3">
  39.                         project line name
  40.                     </div>                    
  41.                 </div> 
  42.                 <div class="form-group row task" id="12">
  43.                     <div class="col col-sm-1">
  44.                         <input type="checkbox" class="form-control form-control-sm checkbox" name="makeTask">
  45.                     </div>
  46.                     <div class="col col-sm-2">
  47.                         <input type="text" class="form-control form-control-sm" name="deadline" >
  48.                     </div>
  49.                     <div class="col col-sm-2">
  50.                         <input type="text" class="form-control form-control-sm" name="collaborator">
  51.                     </div>
  52.                     <div class="col col-sm-3">
  53.                         <input type="text" class="form-control form-control-sm" >
  54.                     </div>
  55.                     <div class="col col-sm-1">
  56.                         <input type="time" class="form-control form-control-sm" >
  57.                     </div>
  58.                     <div class="col col-sm-3">
  59.                         project line name
  60.                     </div>                    
  61.                 </div> 
  62.                 <button type="submit"  class="btn btn-primary" id="submit-button">Maak taken aan in th!nx</button>
  63.                 <button type="submit" class="btn btn-secondary">Terug naar th!nx</button>
  64.             </form>

If the user wants to plan a project-line, he ticks the first checkbox (make-Task). If this checkbox is ticked, the second field (deadline) is required. If it's not ticked, it's not required (because we won't plan it).

1) How can I check if the deadline field is not empty, only if the first field is ticked
2) My validation ONLY looks at the first row, doesn't validated the others (I just set deadline to always be required when playing around and noticed this. How do I check the other rows ?

PS my 'play-around' validation file :     <script src="validation.js"></script> looked like :

  1. $(function() {
  3.     $("#task-form").validate({
  5.         rules : {
  6.             deadline: {
  7.                 required: true
  8.             }
  9.         }
  10.     });
  12. })