The “Restrict Dates” feature allows you to set limitations on date fields within your form. This feature is useful when you want to restrict users from selecting certain dates, such as past dates or specific ranges.
With this, you can improve the user experience and ensure that users select valid dates within your specified criteria. Whether it’s preventing users from selecting past dates, limiting future date selections, or defining a specific date range, this feature adds flexibility and control to your form design.
Table of contents:
Getting started
Step 1: Install the Plugin
Once you’ve chosen a plugin, you’ll need to install it on your website. Log into your WordPress admin dashboard. Navigate to the “Plugins” section and click on “Add New.” Search for the plugin by name and click “Install Now” once you find it.
Step 2: After installation, click on “Activate” to activate the plugin.
How to add restricted date fields?
- Step 1: Edit Your Form: Begin by creating a new form
- Step 2: Add a Date Field: Drag and drop the Form widget onto the desired section of your page.
- Step 3: Set Minimum and Maximum Dates: Look for the “Min Date” and “Max Date” options within the Field Options. These settings allow you to define the minimum and maximum allowable dates for user selection.
There are 3 types:
+ None: There will be no date limit for selection. Users can select past, present, and future dates
+ Current date: it means that you want to restrict users from selecting a date before the current date.
+ Set date: you can choose any dates as minimum and maximum date
Restrict dates settings
How to set specified range days?
This allows users to select a start date and an end date within a specified range.
Step 1: Find Min/Max options to configure the minimum and maximum number of days for the range.
- Specify the minimum number of days that a user can select as the start date.
- Specify the maximum number of days that a user can select as the end date.
Step 2: For example, in the Schedule field, we set the Min date as 01-05-2024 and the Max date as 12-05-2024.
Step 3: Save and see a preview: Any date between the ranges can be chosen.
How to link two date pickers?
To link two date pickers, where the selection in one date picker affects the available options in the other, you can follow these steps:
Let’s say you have two date pickers: “Check-in Date” and “Check-out Date”. The goal is to restrict the available options in the “Check-out Date” picker based on the selected “Check-in Date”.
- When a user selects a “Check-in Date”, the “Check-out Date” picker should only allow dates on or after the selected “Check-in Date”.
- If the user changes the “Check-in Date”, the options in the “Check-out Date” picker should update accordingly.
Step 1: Add two Date fields for the “Check-in Date” and “Check-out Date”. Set Min and Max date sequentially.
Step 2: Link 2 field
Locate Check-in Date:
- At Link Max Field – Show Smart Tags – Choose Check-out Date
Locate Check-out Date:
- Link Min Field – Show Smart Tags – Choose Check-in Date
Step 3: Save and Have a look.
If you choose the 16th for check-in, check-out must be after the 16th.
How to add an exception?
Exceptions allow you to negate the date limitations established in the other settings.
An exception works with both selectable dates and unselectable dates. If the excepted date is selectable, it will now be unselectable. If the excepted date is unselectable, it will now be selectable.
E.g:
If May 6th through May 16th are selected for the next appointment. But if you would like to allow a specific May 13th to be unselectable, you can add an “exception” for that 13th. Click the Add Exception button and select the desired date from the date picker.
Days of week
This setting allows you to restrict which dates are selectable based on the days of the week (e.g. Monday – Sunday).
By default, all days are allowed. Uncheck all days option to select specific days.
Min/Max number of dependent days
Min/Max number of dependent days” refers to the minimum/maximum duration or number of days that a dependent entity relies on or is influenced by another entity.
E.g:
If Check-out is dependent on Check-in and the “min number of dependent days” is 3, it means that Check-out can start at least 3 days after Check-in.
To do this:
At Check-in Date – Navigate to Min number of dependent days – Typing 3
Have a preview:
Check-in: 05-05-2024.
Check-out: You can choose from 8th.
That’s it! We hope this article helped you find out how to use Restrict dates with your WPForms.