Hi i want to set default maxDate 9 days after I select input first. here is my code HTML
<input type="text" placeholder="Date" name="daterange" class="form-control date-picker form-date" id="date-picker" />
<input type="text" placeholder="Date" name="daterange" class="form-control date-picker-2 form-date" id="date date-picker-2"/>
and JS
$('.date-picker').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
minDate: moment().subtract(1, 'years'),
maxDate: moment().subtract(1, 'days'),
locale: {
format: 'DD-MM-YYYY'
}
}
var departpicker = $('.date-picker').val();
$('.date-picker-2').daterangepicker({
minDate: departpicker,
//here is the bug
maxDate: moment().add(9, 'days')
});
In my mind is how to departpicker
+ 9 days. I try departpicker.add(9, 'days')
doesnt work. Any body help? For example when I select 1 July 2018 on first input and maxDate on second input is 10 July 2018 my full code https://jsfiddle.net/dedi_wibisono17/Lmjv9hp2/7/ Thank you
You should specify the date format before adding 9 days.
$('.date-picker-2').daterangepicker({
minDate: departpicker,
//here is the bug
maxDate: moment(departpicker, 'DD-MM-YYYY').add(9, 'days');
});
You can use the maxSpan option
"maxSpan": {
"days": 9
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.