I want to get the object of the 2nd input. Since I have more inputs with class 'check-date2', I want to get the element immediately after the first.
HTML
<div class="form_line">
<div class="column-50">
<div class="line_desc">
Data Início<font>*</font>
</div>
<div class="line_field">
<div class="form-group">
<input id="datepicker1"
class="form-control input date-check check-date"
placeholder="Data Início - DD-MM-YYYY" type="text"
name="event_date_start">
</div>
</div>
</div>
<div class="column-50">
<div class="line_desc">
Data Fim<font>*</font>
</div>
<div class="line_field">
<div class="form-group">
<input id="datepicker2"
class="form-control input date-check check-date2"
placeholder="Data Fim - DD-MM-YYYY" type="text"
name="event_date_end">
</div>
</div>
</div>
</div>
No. I have this:
$(".check-date").on("change", function() {
checkIfSecondDateIsGreaterThanFirst(this);
});
And the function that should take the input object:
function checkIfSecondDateIsGreaterThanFirst(date) {
/**
* to verify that the second data is greater than the first
*/
var next_date = $(date).next('.check-date2');
alert($(next_date).attr('class'));
}