# Restrict Date Picker for 24hours in Advance

**URL:** <https://community.gravityforms.com/t/restrict-date-picker-for-24hours-in-advance/12541>\
**Category:** Get Help\
**Tags:** gform\_datepicker\_options\_pre\_init\
**Created:** [May 3, 2022, 7:19am UTC](https://community.gravityforms.com/t/restrict-date-picker-for-24hours-in-advance/12541 "2022-05-03T07:19:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![user5b725a62377f32.4](https://avatars.discourse-cdn.com/v4/letter/u/858c86/32.png) [@user5b725a62377f32.4](https://community.gravityforms.com/u/user5b725a62377f32.4)\
**Post date:** [May 3, 2022, 7:19am UTC](https://community.gravityforms.com/t/restrict-date-picker-for-24hours-in-advance/12541/1 "2022-05-03T07:19:18Z")

</div>

Hi,

We have a client. To be able to prevent last-minute bookings in the date picker for reservations. So, for example, a person can not book for tonight’s dates for instance. So we want to restrict individuals from booking items last minute. We need to limit the date picker to not be able to select a date within 24hours of the date chosen. So today’s date will be greyed out as such and not an option to select. Is this even possible and what is code?

Lisa

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [May 3, 2022, 12:28pm UTC](https://community.gravityforms.com/t/restrict-date-picker-for-24hours-in-advance/12541/2 "2022-05-03T12:28:05Z")

</div>

Please see example 9 here:

> **[gform\_datepicker\_options\_pre\_init](https://docs.gravityforms.com/gform_datepicker_options_pre_init/#h-9-disable-past-dates)**
>
> This filter can be used to modify the options used to initialize a fields datepicker.

With that you can prevent past dates or ensure that the date is one day in the future, two days, etc. This line prevents past dates:

```auto
optionsObj.minDate = 0;

```

If you wanted to ensure that today cannot be selected either, change it to this:

```auto
optionsObj.minDate = 1;

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [June 2, 2022, 12:28pm UTC](https://community.gravityforms.com/t/restrict-date-picker-for-24hours-in-advance/12541/3 "2022-06-02T12:28:48Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
