datepicker UI Arrival and Departure Fields
I have a WordPress form on my
client's hotel website with an arrival field and a departure field. The client wants the departure date to add +1 day to the minDate when a user selects the arrival date. I have tried adding +1 to several areas but nothing seems to work. I have attached the script I am using (it's using jQuery instead of $ because the form is in a code block in WordPress). I have searched several forums and Google searches with no success.
- <script>
- jQuery(function() { var dateFormat = "M dd,yy",
- from = jQuery( ".check-in-date-view" )
- .datepicker({
- minDate: 0,
- maxDate: "+12m",
- defaultDate: "+1w",
- dateFormat: "M dd,yy",
- altFormat: "mm/dd/yy",
- altField: ".arrival-date",
- changeMonth: true,
- changeYear: true,
- numberOfMonths: 1
- })
- .on( "change", function() {
- to.datepicker( "option", "minDate", getDate( this ) );
- }),
- to = jQuery( ".check-out-date-view" ).datepicker({
- defaultDate: "+1w",
- minDate: 1,
- maxDate: "+12m",
- dateFormat: "M dd,yy",
- changeMonth: true,
- altFormat: "mm/dd/yy",
- altField: ".departure-date",
- changeYear: true,
- numberOfMonths: 1
- })
- .on( "change", function() {
- from.datepicker( "option", "maxDate", getDate( this ) );
- });
- jQuery(".check-in-date-view").datepicker("setDate", new Date());
- jQuery(".check-out-date-view").datepicker("setDate", 1);
- function getDate( element ) {
- var date;
- try {
- date = jQuery.datepicker.parseDate( dateFormat, element.value );
- } catch( error ) {
- date = null;
- }
- return date;
- }
- } );
- jQuery(".promo-trigger").click(function(){
- jQuery(".flyout-wrapper").toggle();
- });
- </script>