I have a text box with a datepicker on my page. Initially, there is only one, but there can be more added dynamically. The first datepicker is set up so that the user cannot choose a date before today, but can choose any date in the future.
How can I set up the next datepickers so that the user cannot choose a date before the date chosen in the previous date pickers? For example: If today is 25.02.2019 and I choose 01.03.2019 in the first datepicker, then the second date picker shouldn't be able to choose anything before 01.03.2019.
If I select 10.03.2019 in the second datepicker, then the next generated datepicker shouldn't be able to choose anything before 10.03.2019.
Heres what I have so far:
$(".flightDate").datepicker({ minDate: 0 });
$('body').on('focus',
'.dynamic-flightdate',
function () {
$(this).datepicker({
numberOfMonths: 1,
firstDay: 1,
defaultDate: 0,
minDate: function () {
$(this).prev(".datepicker").val();
console.log($(this).prev(".datepicker").val());
},
changeMonth: true,
changeYear: true,
dateFormat: 'dd.mm.yy'
});
$(this).datepicker('show');
});
but it does not bring back any value in the console.log call