We realized that hiding the departure date will not solve the issue. The problem is users are selecting a departure date that is before the arrival date. We used the below code to stop this from happening, but it only seems to work in Chrome and not for our other users that prefer Safari or Firefox. Is there any way to make it work on all browsers?
Thanks
jQuery(window).load(function() {
var fromId = jQuery('input[name="wpcf-arrival-date[display-only]"]').attr('id');
var toId = jQuery('input[name="wpcf-departure-date[display-only]"]').attr('id');
var $from = jQuery( '#' + fromId );
var $to = jQuery( '#' + toId );
var alt_filed_arrival = jQuery('input[name="wpcf-arrival-date[datepicker]"').attr('id');
var alt_filed_departure = jQuery('input[name="wpcf-departure-date[datepicker]"').attr('id');
$from.datepicker('option', 'dateFormat', 'dd/mm/yy' );
$from.datepicker('option', 'minDate',0);
$from.datepicker('option', 'onSelect', function( selectedDate, obj ) {
if(selectedDate) {
var sd = selectedDate.split("/");
stamp = new Date(Date.UTC(sd[2], sd[1]-1, sd[0])).getTime();
stamp = parseInt(stamp/1000);
jQuery('#'+alt_filed_arrival).val(stamp);
$to.datepicker( "option", "minDate", selectedDate );
}
});
$to.datepicker('option', 'dateFormat', 'dd/mm/yy' );
$to.datepicker('option', 'minDate',0);
$to.datepicker('option', 'onSelect', function( selectedDate, obj ) {
if(selectedDate) {
var sd = selectedDate.split("/");
var newDate = sd[1]+"/"+sd[0]+"/"+sd[2];
stamp = new Date(Date.UTC(sd[2], sd[1]-1, sd[0])).getTime();
stamp = parseInt(stamp/1000);
jQuery('#'+alt_filed_departure).val(stamp);
$from.datepicker( "option", "maxDate", selectedDate );
}
});
});