### [Limiting Options for the Date / Time Field](https://wpforms.com/docs/how-to-limit-options-for-the-date-time-field/)

**Published:** November 23, 2023
**Author:** Umair Majeed

**Excerpt:** Learn how to limit the dates and times that can be selected on your form.

**Content:**

Would you like to restrict what date and time options can be selected in your WordPress forms? For example, if your office is only open from 9am-5pm, Monday through Friday, then you might want to prevent visitors from making an appointment outside of those days and times.

This tutorial will show you how to limit options for the Date / Time field in WPForms.

- [Adding a Date / Time Field](#adding-date-time-field)
- [Limiting Available Dates and Times](#limiting-dates-and-times)
- [Frequently Asked Questions](#faq)

Please enable JavaScript in your browser to complete this form.

##### Try this Form Demo!

Select a date and time for your appointment.

Date

Time

Submit![Loading](https://wpforms.com/wp-content/plugins/wpforms/assets/images/submit-spin.svg)

 ---

Before getting started, you’ll first need to make sure WPForms is [installed and activated](https://wpforms.com/docs/install-wpforms-plugin/ "How to Install the WPForms Plugin") on your WordPress site, and that you’ve [verified your license](https://wpforms.com/docs/verify-wpforms-license/ "How to Verify Your WPForms License"). Then, you can [create a new form](https://wpforms.com/docs/creating-first-form/ "How to Create Your First Form") or edit an existing one to access the form builder.

## Adding a Date / Time Field

Once the form builder is open, look under the **Fancy Fields** section to find the **Date / Time** field. Simply click on it or drag and drop it into the preview area to add it to your form.

![Add date time field](https://wpforms.com/wp-content/uploads/2021/11/add-date-time-field.png)## Limiting Available Dates and Times

To select certain dates and times that your site visitors can choose in your forms, click on the **Date / Time** field in the preview area to open its **Field Options**.

![Click date time field for field options](https://wpforms.com/wp-content/uploads/2021/11/click-date-time-field-for-field-options.png)Next, within the Field Options panel, click on the **Advanced** tab to open the field’s advanced options.

![Click advanced tab](https://wpforms.com/wp-content/uploads/2021/11/click-advanced-tab-2.png)This will open up additional settings that you can customize, including options to **Limit Days** and **Limit Hours**. We’ll go over both of these options in the following sections.

### Limiting the Date

In order to limit which days are available for your users to choose, you’ll need to select the **Limit Days** option.

![Enable limit days option](https://wpforms.com/wp-content/uploads/2021/11/enable-limit-days-option.png)This will open up a list of days that you can enable or disable within your forms. Be sure to check the boxes for the days you’d like to allow your users to choose, and leave any boxes unchecked for days you’d like to block from your users.

![Check or uncheck days](https://wpforms.com/wp-content/uploads/2021/11/check-or-uncheck-days.png)### Disabling Past Dates

In addition to selecting which days of the week are available for your users to choose, you can also prevent them from selecting past dates within your forms. To do this, you’ll just need to select the **Disable Past Dates** option.

![Disable past dates](https://wpforms.com/wp-content/uploads/2021/11/disable-past-dates.png)When dates are disabled, they will appear greyed out on the frontend of your site.

![Past dates disabled](https://wpforms.com/wp-content/uploads/2023/06/disable-past-days-and-weekends.png)If you’d like to further customize the date options, be sure to check out our [developer documentation](https://wpforms.com/developers/customize-the-date-time-field-date-options/) for more details. To help prevent code conflicts, be sure to disable any date limitations within the form builder before adding any custom code.

### Limiting the Time

Similarly, you can limit which hours are available for your users to choose from within your forms. To do this, you’ll first need to select the **Limit Hours** option.

![Enable limit hours](https://wpforms.com/wp-content/uploads/2021/11/enable-limit-hours.png)After this is enabled, you’ll see additional options for configuring the **Start Time** and **End Time** of your hours. For each of these settings, you can click the dropdown and select the hours you’d like shown to your site visitors.

If you’d like to preview a customizable form template that showcases the Date / Time field limiting feature, check out our [Movie Ticket Booking Form Template](https://wpforms.com/templates/movie-ticket-booking-form-template "Movie Ticket Booking Form Template").

![Click hour dropdown](https://wpforms.com/wp-content/uploads/2021/11/click-hour-dropdown.png)On the frontend of your site, all available times between the selected Start Time and End Time will be available for your users to choose from.

Need to disable past times on the Time Picker for more accurate appointment bookings? Be sure to check out our [developer documentation](https://wpforms.com/developers/how-to-disable-past-times-on-the-time-picker/) for more information.

## Frequently Asked Questions

These are answers to some top questions we receive about limiting the options for the Date / Time field.

#### How do I disable future dates when using the Date Picker option?

To disable future dates, you’ll need to add a custom code snippet to your WordPress site. Below is the snippet to add to your site.

If you need help with [adding code snippets to your site](https://wpforms.com/how-to-add-custom-code-snippets-in-wordpress/), be sure to check our guide to learn how.

**Note:** The code snippet above will only work for form ID 323 and field ID 4. To use this code for different forms or fields, you’ll need to update these ID numbers in the code. See our tutorial on [how to locate form ID and field ID](https://wpforms.com/developers/how-to-locate-form-id-and-field-id/) to find the correct IDs for your forms.

#### Can I limit the Date / Time field based on the input of another field?

If you have 2 Date / Time fields on your form, you can compare both dates to prevent users from selecting a date older than the one on the first Date / Time field. This can be useful when creating a form that allows users to specify their order and pickup date.

For more details, be sure to check our guide to learn [how to compare 2 Date / Time fields](https://wpforms.com/developers/how-to-compare-two-dates-in-the-same-form/).

That’s it! We just showed you how to limit the options for the Date / Time field in WPForms.

Next, would you like to change the appearance of the Date / Time field in your WordPress forms? Be sure to check out our tutorial on [customizing the Date / Time field](https://wpforms.com/docs/how-to-customize-the-date-time-field-in-wpforms/ "How to Customize the Date / Time Field in WPForms") for more details.

**Categories:** Fields, Field Customizations

---

