How do I get the daterangepicker when clicking on the date field back but allow me to change the date of exit ("endDate" )?
My code:
var currentDate = moment().format("DD/MM/YYYY");
$('input[name="date-entrada"], input[name="date-saida"]').daterangepicker({
locale: {
format: 'DD/MM/YYYY'
},
"alwaysShowCalendars": true,
"minDate": currentDate,
"maxDate": moment().add('months', 1),
"startDate": $('input[name="date-entrada"]').val(),
autoUpdateInput: false
}, function (start, end, label) {
var selectedStartDate = start.format('DD/MM/YYYY'); // selected start
var selectedEndDate = end.format('DD/MM/YYYY'); // selected end
var $checkinInput = $('input[name="date-entrada"]');
var $checkoutInput = $('input[name="date-saida"]');
$checkinInput.val(selectedStartDate);
$checkoutInput.val(selectedEndDate);
var checkOutPicker = $checkoutInput.data('daterangepicker');
checkOutPicker.setStartDate(selectedStartDate);
checkOutPicker.setEndDate(selectedEndDate);
var checkInPicker = $checkinInput.data('daterangepicker');
checkInPicker.setStartDate(selectedStartDate);
checkInPicker.setEndDate(selectedEndDate);
});
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script><scripttype="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script><scripttype="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script><linkrel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
<input type="text" placeholder="Data" name="date-entrada" value="20/11/2018"/>
<input type="text" placeholder="Data" name="date-saida" value="25/11/2018"/>
Can anyone help me?