I want to set minDate
on Date to calendar #dateto
without disabling previous months.
By default the calendar #datefrom
and #dateto
have set property minDate
to today
Take for example that the today
date 2019-2-8
The goal is to select the date 2019-5-15
from the '#datefrom' calendar and set this date in the #dateto
calendar as minDate
, and the calendars #dateto
will be set to 2019-5 -15
as minDate
and I want to move normally to month 2, now I can not because I was blocked in previous months.
Date from
$('#datefrom').datepicker({
stepMonths: 1,
numberOfMonths: 2,
minDate : 'today',
dateFormat: 'yy-mm-dd',
showOtherMonths: true,
onSelect: function(date){
$('.datefrom-text').text(date);
$('#dateto').datepicker('option', 'minDate', date);
}
});
Date to
$('#dateto').datepicker({
stepMonths: 1,
numberOfMonths: 2,
minDate : 'today',
dateFormat: 'yy-mm-dd',
showOtherMonths: true,
onSelect: function(date){
$('.dateto-text').text(date);
}
});
I managed to move calendars by calling internal datepicker method, so I hope it will help you to get what you need. Check my jsfiddle fork
$.datepicker._selectMonthYear( '#dateto', document.getElementById("fakeMonthSelected"), "M" );
Davor