Reputation: 33
I have 2 input boxes with datepicker. I want following validations
$('#startdate').datepicker({
format: 'dd-mm-yyyy',
autoclose: true,
weekStart: 1,
endDate: "today"
});
$('#enddate').datepicker({
language: 'nl',
format: 'dd-mm-yyyy',
autoclose: true,
weekStart: 1,
endDate: "today"
});
First validation is working fine. Please help me with other 2 validations. Thanks in advance
Upvotes: 2
Views: 106
Reputation: 722
You can try this
Since your 1st condition is working I have included condition 2 and 3 in changeDate function
$('#startdate').datepicker({
format: 'dd-mm-yyyy',
autoclose: true,
weekStart: 1,
endDate: "today"
}).on('changeDate', function(){
// set the "enddate" start to not be later than "startdate"
$('#enddate').datepicker('setStartDate', new Date($(this).val()));
$('#enddate').datepicker('setEndDate', '+1y');
});
$('#enddate').datepicker({
language: 'nl',
format: 'dd-mm-yyyy',
autoclose: true,
weekStart: 1,
endDate: "today"
});
Upvotes: 2