This is because it currDatecan be empty.
If currDateemtpy $('.currDate').datepicker('getDate')returns null, in this case it date2.setDate(date2.getDate()+1);may display an error
Update:
$(function() {
$('#nxtDate').datepicker({
dateFormat: "dd-M-yy",
});
$("#currDate").datepicker({
dateFormat: "dd-M-yy",
minDate: 0,
onSelect: function(date){
var date2 = $('#currDate').datepicker('getDate');
date2.setDate(date2.getDate()+1);
$('#nxtDate').datepicker('setDate', date2);
}
});
})
source
share