1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
$('#checkin').datepicker('destroy');// it destroy old date picker data $('#checkin').datepicker({ showButtonPanel: false, minDate: maxdate, dateFormat: 'dd/mm/yy', onSelect: function () { var dt2 = $('#checkout'); var startDate = $(this).datepicker('getDate'); var minDate = $(this).datepicker('getDate'); var dt2Date = dt2.datepicker('getDate'); //difference in days. 86400 seconds in day, 1000 ms in second var dateDiff = (dt2Date - minDate)/(86400 * 1000); startDate.setDate(startDate.getDate() + 30); if (dt2Date == null || dateDiff < 0) { // dt2.datepicker('setDate', minDate); } else if (dateDiff > 30){ // dt2.datepicker('setDate', startDate); } //sets dt2 maxDate to the last day of 30 days window dt2.datepicker('option', 'maxDate', startDate); dt2.datepicker('option', 'minDate', minDate); } }); $('#checkout').datepicker({ showButtonPanel: false, minDate: 0, dateFormat: 'dd/mm/yy' }); |
Leave a reply