I am trying one of the example given in flatpickr which is Check in check out. The example is working fine but when I use same syntax in the local machine it is not working like check-out date is able to select the previous date of check-in date.
var check_in = document.getElementById("check_in_date").flatpickr({
altInput: true,
altFormat: "F j Y",
minDate: new Date()
});
var check_out = document.getElementById("check_out_date").flatpickr({
altInput: true,
altFormat: "F j Y",
minDate: new Date()
});
check_in.config.onChange = function(dateObj) {
check_out.set("minDate", dateObj.fp_incr(1));
};
check_out.config.onChange = function(dateObj) {
check_in.set("maxDate", dateObj.fp_incr(-1));
}
This is working
check_in_date = flatpickr("#check_in_date", {
onChange: function(selectedDates, dateStr, instance) {
check_out_date.set('minDate', selectedDates[0]);
}
});
check_out_date = flatpickr("#check_out_date", {});
<link href="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.11/flatpickr.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.11/flatpickr.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" id="check_in_date" name="checkin">
<input type="text" id="check_out_date" name="checkin">