No matter what I try, I\'m not able to get the beforeShow event to fire on my datepicker. Here\'s my code:
$(\'#calendar\').datepicker({
inline: true,
dateF
I wanted to use beforeShow to update the minumum date on an end date datepicker to reflect the date set in the start date datepicker. I have revewed a number of solutions posted here and elsewhere which were complicated. I may be missing something but the following quite straight forward code works for me.
This resets the focus to the start date if none yet set and an attempt is made to enter an end date. If a start date has been set it sets the minimum date for the end _Date appropriately.
$(function(){
$("#start_Date").datepicker({
changeMonth: true,
changeYear: true,
yearRange: "c-1:c+5",
dateFormat: "dd-mm-yy"
});
$("#end_Date").datepicker({
changeMonth: true,
changeYear: true,
yearRange: "c-1:c+5",
dateFormat: "dd-mm-yy",
beforeShow: end_Range
});
function end_Range(){
if ($("#start_Date").datepicker("getDate") == null ){
$("#start_Date").focus();
} else {
// set minimum date range
$("#end_Date").datepicker("option", "minDate", new Date ($("#start_Date").datepicker("getDate")));
};
};
});
With date fields: