Find trending topics and quick answers here

Hi, how can we help?

There no matching results.

How to restrict the end date to 15 days after the start date

Question

How can I limit the end date to 15 days after the start date in my form?


Description

I have a form that collects a start date and an end date to track an approval period. I want to set a condition so that the end date cannot be more than 15 days after the start date—it must be within 15 days of the start date. Can PlatoForms help me achieve this?


Answer

Certainly! To achieve this, you’ll need to:

  1. Add Fields:

    • Start Date: The date entered by the user as the start date.
    • End Date: The date entered by the user as the end date.
    • Calculation Field: A hidden date field that stores the result of the start date plus 15 days.
  2. Set Up Logic:

    • Create a rule to automatically add 15 days to the Start Date and store this result in the hidden Calculation Field.
  3. Add Validation Rule:

    • In the End Date field, add a rule to check if the entered End Date is later than the date in the hidden Calculation Field (i.e., the Start Date plus 15 days). If the End Date is later, an error message will appear, preventing the form from being submitted.

For more details, refer to the step by step guide below:


Step by step guide

Step 1: Add start and end date field

Add a Start Date and an End Date field.

Step 2: Add a date calculation field

  1. Add a date calculation field to your form and configure it to be hidden.

    Add Extra Date Field

  2. To ensure it doesn’t display on the form or affect your PDF, select Hidden on form and uncheck Print in PDF.

    Extra Date Field Settings

This field will be used to calculate the date range and won’t be visible to users.

Step 3: Calculate 15 days from the start date

  1. Create a logic rule in your form builder that adds 15 days to the start date and assigns this value to the data calculation field.

    Calculate 15 Days

Step 4: Set up validation for the end date

Go to the End Date field settings and add a validation rule that checks the end date against the extra date field, and also add an error message.

Validate End Date

This will ensure the end date does not exceed 15 days from the start date.


Test the demo

For a practical example, test this setup using the demo form. The date calculation field is visible in the demo to help you understand how it works.

Validate End Date


Have more questions? Visit our FAQs page or contact us.