I have a webform with arrival and departure dates working.
Now I would like the minimum departure date to be automatically one day after arrival.
My code (taken from some example):

  Drupal.behaviors.setDeparture = function (context) {

      $("#webform-component-arrival input.webform-calendar").datepicker({
          onSelect: function( selectedDate ) {
            // Parse the selected date
            var instance = $( this ).data( "datepicker" ),
                date = $.datepicker.parseDate(
                    instance.settings.dateFormat ||
                    $.datepicker._defaults.dateFormat,
                    selectedDate, instance.settings );

            // Add one day
            date.setDate(date.getDate()+1);

            // Set the new date
            $("#webform-component-departure input.webform-calendar").datepicker('setDate', date);               
        }
      });
      $("#webform-component-departure input.webform-calendar").datepicker();

      $("#webform-component-arrival input.webform-calendar").datepicker('setDate', new Date());
  };

Can someone please tell me why this code wont work?

Comments

quicksketch’s picture

Status: Active » Closed (won't fix)

Hi @netwurst. We don't provide support on custom coding questions in the Webform issue queue. You might try using the Drupal StackExchange site for specific coding questions like this.

netwurst’s picture

Thanks quickketch, I´ll try this.