Score:0

Populate a 2nd date field min date from a previous date field in webform before submission

jp flag

I have 2 date fields on a webform. The 1st date field has a min date set

first_date:
  '#type': date
  '#title': 'First Date'
  '#date_date_min': 'today + 3 days'
  '#datepicker': true
  '#date_date_format': 'l, F j, Y'

The 2nd date field needs to be populated with a minimum date, reflecting the date entered into the 1st date field so that the user cannot select a date before the date entered into the 1st date field.

second_date:
  '#type': date
  '#title': 'Second Date'
  '#datepicker': true
  '#date_date_format': 'l, F j, Y'

As in the image below, the user can select a date for the 2nd date field before the date entered into the 1st date field.

This needs to happen on the form entry before the form is submitted.

Is this possible within the scope of the Webform module or does it require some javascript?

I have read that this is possible using the function drupal_process_states

I'm not a coder. Just asking for help/direction. Thanks

enter image description here

ru flag
This is usually done with JavaScript on client side. Many popular datepicker JS libs support this use case. I'm not sure, but your screenshot looks like jQuery UI datepicker, this might be a starter: https://stackoverflow.com/questions/4419804/restrict-date-in-jquery-datepicker-based-on-another-datepicker-or-textbox
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.