I have a form where I have three input fields (one as date, one as start time and the other as end time) which are in arrays. Like this:-
<input type="text" class="form-control datetimepicker-input" data-target="#sDatePicker_1" data-toggle="datetimepicker" id="sdating_1" name="sdate[]" placeholder="Select Day"/>
<input type="text" class="form-control datetimepicker-input" data-target="#fromTimePicker_1" data-toggle="datetimepicker" id="stime_1" id="stime[]" placeholder="HH : MM"/>
<input type="text" class="form-control datetimepicker-input" data-target="#toTimePicker_1" data-toggle="datetimepicker" id="etime_1" id="etime[]" placeholder="HH : MM"/>
<input type="text" class="form-control datetimepicker-input" data-target="#sDatePicker_2" data-toggle="datetimepicker" id="sdating_2" name="sdate[]" placeholder="Select Day"/>
<input type="text" class="form-control datetimepicker-input" data-target="#fromTimePicker_2" data-toggle="datetimepicker" id="stime_2" id="stime[]" placeholder="HH : MM"/>
<input type="text" class="form-control datetimepicker-input" data-target="#toTimePicker_2" data-toggle="datetimepicker" id="etime_2" id="etime[]" placeholder="HH : MM"/>
<input type="text" class="form-control datetimepicker-input" data-target="#sDatePicker_3" data-toggle="datetimepicker" id="sdating_3" name="sdate[]" placeholder="Select Day"/>
<input type="text" class="form-control datetimepicker-input" data-target="#fromTimePicker_3" data-toggle="datetimepicker" id="stime_3" id="stime[]" placeholder="HH : MM"/>
<input type="text" class="form-control datetimepicker-input" data-target="#toTimePicker_3" data-toggle="datetimepicker" id="etime_3" id="etime[]" placeholder="HH : MM"/>
I am using jQuery validate to validate the form. I need a jQuery form validation rule with specific requirement:
- The date value can be same in multiple
sdate[]
field. This is because user can give multiple training session in one day. - If
sdate[]
value is same for mulitple rows, then the value ofstime[]
andetime[]
of one row must not clash/conflict or fall within the time period of any otherstime[]
andetime[]
field have samesdate[]
value.
For example, if s_date_1
and s_date_2
is both 07/10/2019 and if stime_1
and etime_1
is 08.00 AM
and 9.00 AM
, then stime_2
can't be 08.30 AM
.
I know jQuery validation, but in this case I am clueless about how to start.