Это будет работать
$("#FirstCal").datepicker({
dateFormat: 'M d, yy',
navigationAsDateFormat: true, prevText: 'M', nextText: 'M',
changeMonth: true,
changeYear: true,
showOn: "both",
showStatus: true,
firstDay: 0,
changeFirstDay: false,
beforeShow: customRange,
buttonImage: '/Content/images/Calendar_img.png',
buttonImageOnly: true
});
$("#secondCal").datepicker({
dateFormat: 'M d, yy',
navigationAsDateFormat: true, prevText: 'M', nextText: 'M',
changeMonth: true,
changeYear: true,
showOn: "both",
showStatus: true,
firstDay: 0,
changeFirstDay: false,
beforeShow: customRange,
buttonImage: '/Content/images/Calendar_img.png',
buttonImageOnly: true
});
function customRange(input) {
var min = new Date();
var min = new Date('<%=DateTime.Now.Year %>', '0', '1');
var max = new Date('<%=DateTime.Now.AddYears(1).Year %>', '11', '31');
var dateMin = min;
var dateMax = max;
if (input.id == "firstCal" && $("#secondCal").datepicker("getDate") != null) {
if (dateMin < min) {
dateMin = min;
}
}
else if (input.id == "secondCal") {
if ($("#firstCal").datepicker("getDate") != null) {
dateMin = $("#firstCal").datepicker("getDate");
}
}
return {
minDate: dateMin,
maxDate: dateMax
};
}