Document – Contact form 7 – Restrict dates

Restrict Dates Contact Form 7 add-on is that restricts users from selecting specific dates in your Contact Form 7 date picker field.

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 use this limit date add-on?

In the context of forms or user interfaces, restricting dates means setting certain rules or limitations on the dates that users can choose or interact with. This can include:

  • Minimum Date: Setting a minimum date restricts users from selecting any date prior to the specified minimum date. For example, if the minimum date is set to today’s date, users will not be able to choose a date in the past.
  • Maximum Date: Setting a maximum date restricts users from selecting any date beyond the specified maximum date. This can be useful when you want to limit the date selection to a certain range or prevent users from choosing dates too far in the future.
  • Date Range: In some cases, you may want to restrict date selection to a specific range. For example, if you have a booking system, you might allow users to select dates only within a certain period, such as within the next 30 days.
  • Exceptions: Exceptions provide the ability to exclude certain dates from the available selection range. For example, you might want to exclude holidays, specific blackout dates, or any other dates that are not suitable for selection. By specifying exceptions, you can restrict users from choosing those specific dates.
  • Day of the Week Restrictions: Day of the week restrictions allow you to control which days of the week are available for selection. This can be useful in scenarios where you want to limit users to specific days, such as scheduling appointments only on weekdays or allowing bookings on weekends only.

These date restrictions can help ensure data accuracy, prevent invalid or inappropriate selections, and align with specific requirements or business rules in various applications and systems. Creating a restrict date as soon as possible.

How to add restricted date fields to your forms?

  • Step 1: Create a new form

Hover to the Contact menu, and click on Add new. A new contact form is displayed, give it the title.

Create a new form
  • Step 2: Add a Date field

Inside the form editor, add a new field and select “Date Restrict” This will insert a date field shortcode into your form.

Add a Date field
  • Step 3: Add Restrictions to the Date Field

When you select the Date Restrict, a new window showed like below. Input the min/max date to set date range restrictions.

Add Restrictions to the Date Field

At the Min/Max drop-menu, 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

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, at the Your next appointment field, we set min date is 2023 Oct 5th and max date is 2023 Oct 29th.

<label> Your next appointment
    [date_restrict name_date_530 min:2023-10-05 max:2023-10-29] </label>
How to set specified range days?

Step 3: See a preview

Any date between the ranges can be chosen.

specified range date

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.

<label> Check-in date
   [date_restrict name_date_861 min:2023-10-05] </label>

<label> Check-out date
    [date_restrict name_date_862 max:2023-10-30] </label>
How to link two date pickers?
How to link two date pickers?

Step 2:

Locate Check-in field

Copy name field and paste to Link Min Field of Check-out. 

How to link two date pickers?

Locate Check-out field

Copy name field and paste it to Link Max Field of Check-in.

How to link two date pickers?

Step 3: Save and have a look.

<label> Check-in date
    [date_restrict name_date_861 min:2023-10-05 sync_max:name_date_862] </label>

<label> Check-out date
     [date_restrict name_date_862 max:2023-10-30 sync_min:name_date_861]</label>
limit date
date restriction

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 Oct 6th through Oct 14th are selected for the next appointment. But you would like to make allow a specific Oct 12th to be unselectable, you can add an “exception” for that 12th. Click the Add Exception button and select the desired date from the date picker.

<label> Appointment
   [date_restrict name_date_711 min:2023-10-06 max:2023-10-14 special:2023-10-12] </label>
How to add an exception?

Let’s see a result

restrict date preview

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.

Days of week: This setting allows you to restrict which dates are selectable based on the days of the week (e.g. Monday – Sunday).

Wrapping up

That’s it! We hope this article helped you find out how to use Restrict dates with your contact form 7.