Datepicker Conditions: Prevent overlapping dates

  • countryk9
    Asked on July 23, 2020 at 9:20 PM

    https://form.jotform.com/202047570353146

    Page 9 - Arrival Date field and Departure Date field

    Is it possible to prevent the date selected in the Departure Date field from being before the Arrival Date? For example, I would like to prevent the Departure Date be earlier than the Arrival Date:


    1595553584Date Field Screenshot 10


  • John Support Team Lead
    Replied on July 23, 2020 at 11:57 PM

    Since there is no direct option to automatically disable some dates into a date picket field based on another field's data, I came up with a solution to just warn or inform the user that he's selecting an invalid date.

    Here's what I came up with:

    1. Add a FORM CALCULATION widget to the form. We will calculate the difference between the two date fields (Departure - Arrival):

    Datepicker Conditions: Prevent overlapping dates Image 10

    GUIDEHow-to-Perform-Form-Calculation-Using-a-Widget 

    2. Then add a PARAGRAPH field that will contain a message to the user (shown in the screenshot below in AMBER).

    15955628492468907 2 Screenshot 21

    3. Add a condition to show the said message based on the difference of the said date fields. If it's less than 1, it means that the Arrival Date is the same or is later than the Departure Date, which is not allowed.

    15955629802468907 3 Screenshot 32

    This condition shows the MESSAGE and hides the NEXT button so the user can't proceed to the next page while the Departure date is INVALID.

    You can just hide the FORM CALCULATION widget to your form so the user won't be able to see it.

    I have implemented this into a cloned form. Here's a link to it: https://form.jotform.com/202048876286969?jumpToPage=8


  • countryk9
    Replied on July 24, 2020 at 9:35 AM

    I added an IF for Departure Date Is Filled so it didn't show the message until you picked a date that was earlier. Thank you!