I am using Daterangepicker for our application.
Creating multitrip date picker component (3 input fields)
- TripOne - Select date (Ex: 19th Feb)
- TripTwo - Have to start from 'TripOne' selected date.
- TripThree - Have to start from 'TripTwo' selected date.
Above things are working fine.
But, below issue not working on this plugin.
- TripOne - Select Today date (Not working)
- TripTwo - If Feb 20th selected on TripOne, i cant able to select same Feb 20th on TripTwo.
- TripThree - Similar to TripTwo.
JS:
var nowDate = new Date();
var today = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), 0, 0, 0, 0);
var maxLimitDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate()+360, 0, 0, 0, 0);
$('input[name="tripOne"]').daterangepicker({
"autoApply": true,
"autoUpdateInput": false,
"singleDatePicker": true,
"minDate": today,
"maxDate": maxLimitDate,
"locale": {
format: 'DD MMM YYYY'
}
},function(start) {
$("#tripOne").val(start.format('DD MMM YYYY'));
$('#tripOne').parent().parent().removeClass('has-error');
var returnTripStartDate = new Date(Date.parse(start));
$('input[name="tripTwo"]').daterangepicker({
"autoApply": true,
"autoUpdateInput": false,
"singleDatePicker": true,
"minDate": returnTripStartDate,
"maxDate": maxLimitDate,
"locale": {
format: 'DD MMM YYYY'
}
},function(end) {
$("#tripTwo").val(end.format('DD MMM YYYY'));
$('#tripTwo').parent().parent().removeClass('has-error');
var returnTripStartDate2 = new Date(Date.parse(start));
$('input[name="tripThree"]').daterangepicker({
"autoApply": true,
"autoUpdateInput": false,
"singleDatePicker": true,
"minDate": returnTripStartDate2,
"maxDate": maxLimitDate,
"locale": {
format: 'DD MMM YYYY'
}
},function(end) {
$("#tripThree").val(end.format('DD MMM YYYY'));
$('#tripThree').parent().parent().removeClass('has-error');
});
$(function() {
$('.calendar.right').show();
});
});
$(function() {
$('.calendar.right').show();
});
$('input[name="tripOne"]').on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('DD MMM YYYY'));
});
$('input[name="tripTwo"]').on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('DD MMM YYYY'));
});
$('input[name="tripThree"]').on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('DD MMM YYYY'));
});
});
$(function() {
$('.calendar.right').show();
});