I have a working solution for this issue.
I have two datepickers in my form, I called them startDateTime and stopDateTime. The datepicker code creates two calendars contained in different divs with the ids of startDateTime_datepicker and stopDateTime_datepicker.
Your code will have different names so will have to change these to match what is on your site.
So the rules for my calendar is that the exit date must be at least one day in the future of the entrance date (your rules maybe different) so that is what this code handles.
In the footer section of my site ( just before the final </body></html> tags ) I have placed the following code:
<script>
jQuery(document).ready(function( $ ) {
$('#startDateTime_datepicker').change(function(){
var new_start = $(this).find(".ui-state-hover");
var new_start_date = $.datepicker.parseDate("mm/dd/yy",(parseInt(new_start.parent().attr('data-month'))+1) + "/" + new_start.html() + "/" + new_start.parent().attr('data-year'));
var cur_end = $('#stopDateTime_datepicker').find(".ui-datepicker-current-day");
var cur_end_date = $.datepicker.parseDate("mm/dd/yy",(parseInt(cur_end.attr('data-month'))+1) + "/" + cur_end.find("a").html() + "/" + cur_end.attr('data-year'));
if ( cur_end_date <= new_start_date ) {
var new_end_date = $.datepicker.parseDate("mm/dd/yy",(parseInt(new_start.parent().attr('data-month'))+1) + "/" + (parseInt(new_start.html())+1) + "/" + new_start.parent().attr('data-year'));
$('#stopDateTime_datepicker').datepicker(
"setDate", new_end_date,
"defaultDate", new_end_date
);
}
});
$('#stopDateTime_datepicker').change(function(){
var new_end = $(this).find(".ui-state-hover");
var new_end_date = $.datepicker.parseDate("mm/dd/yy",(parseInt(new_end.parent().attr('data-month'))+1) + "/" + new_end.html() + "/" + new_end.parent().attr('data-year'));
var cur_start = $('#startDateTime_datepicker').find(".ui-datepicker-current-day");
var cur_start_date = $.datepicker.parseDate("mm/dd/yy",(parseInt(cur_start.attr('data-month'))+1) + "/" + cur_start.find("a").html() + "/" + cur_start.attr('data-year'));
if ( new_end_date <= cur_start_date ) {
var new_start_date = $.datepicker.parseDate("mm/dd/yy",(parseInt(new_end.parent().attr('data-month'))+1) + "/" + (parseInt(new_end.html())-1) + "/" + new_end.parent().attr('data-year'));
$('#startDateTime_datepicker').datepicker(
"setDate", new_start_date,
"defaultDate", new_start_date
);
}
});
});
</script>
I hope this works for you as well as it did for me.
Good luck and happy coding.