How to limit dates to weekdays or weekends with Gravity Forms

Limit dates to weekdays, weekends or any other group of days.

Steps

  1. Install GP Limit Dates.
  2. Add a Date field to your form.
  3. Limit dates to Weekdays
  4. Limit dates to Weekends

1. Install GP Limit Dates (via Gravity Perks)

GP Limit Dates is available via Gravity Perks. Install Gravity Perks and then you can install GP Limit Dates (and 46 other Gravity Forms plugins) right from your WordPress admin.

2. Add a Date field to your form.

Under the Advanced Fields field group, click the “Date” field button to add a Date field.

gp-limit-dates-add-date-field

3. Limit dates to Weekdays

Click the “All Days” option to reveal the specific days of the week. Select Monday through Friday to limit the selectable dates in this field to weekdays only.

how-to-limit-dates-to-weekdays

4. Limit dates to Weekends

Click the “All Days” option to reveal the specific days of the week. Select Saturday and Sunday to limit the selectable dates to weekends only.

how-to-limit-dates-to-weekends

Comments

  1. Patrick Rinehart
    Patrick Rinehart September 6, 2024 at 3:31 pm

    I’m trying to set up a form so the user chooses a date 3 business days out. I set it to current date +3 days and do not have Saturday or Sunday checked, but it still counts Saturday and Sunday in the +3 days.

    Reply
    1. Scott Ryer
      Scott Ryer Staff September 6, 2024 at 5:12 pm

      Hi Patrick,

      GP Limit Dates supports the weekday modifier for relative days. This should do the trick: +3 weekdays.

  2. Peter
    Peter October 11, 2022 at 7:14 am

    How can I change the weekends, I want to set weekends as Friday and Saturday. and, remove blocked dates from calculation?

    So, for example if I select a day from Sunday to the Tuesday of the next week (while Monday will be bocked), after calculation, the Number of days, must show 7.

    Please help

    Reply
    1. Dario Space
      Dario Space October 11, 2022 at 9:33 am

      Hi Peter,

      This will require some digging. If you have an active Gravity Perks Advanced or Pro license drop us line via our support form.

      Best,

  3. Hans
    Hans July 30, 2019 at 12:04 pm

    Hello, I would like to use the datepicker for reservations. Obviously I would like to blockout already booked dates, and during the summer I allow reservation of minimal 3 nights and in the winter I only allow bookings for a full week (starting on Sunday) would that be possible with this plugin ?

    Thans hans

    Reply
  4. Jeff
    Jeff March 31, 2017 at 11:07 am

    Hi David,

    I purchased last night! Woo hoo!

    I also copied that code snippet to the end of my functions.php file and I noticed right away that it has errors.

    The editor is telling me that (using your snippet line numbers) lines 1, 86 & 134 are in error. It’s colored them red.

    I tried leaving those lines as is and loaded the updated functions.php to my website and I couldn’t even launch the admin page. I reloaded the original functions.php and my admin page was back to normal.

    I then tried removing the 3 lines mentioned above and copied the updated functions.php back to my website. Same result as before – couldn’t launch my admin page.

    I put back the original functions.php and good again. But I’d really like the functionality that this code snippet is supposed to provide.

    Can you tell me if I’m doing something wrong?

    Thanks!

    Jeff

    Reply
  5. Jeff Bianchi
    Jeff Bianchi March 30, 2017 at 9:15 pm

    Hi David,

    Can you answer a few pre-sale questions about the Date Modifier?

    1. When a customer fills out my form, I give them a 2-business day turnaround for what they’re purchasing from me (I’m using the WooCommerce Gravity Forms addon in my store). Does the Date Modifier (DM) arithmetic take the Days of the Week (DoW) into consideration? For instance, if I have my DoW set to M-F and a customer fills out my form on Thursday and I have the Minimum Date set to Current Date with a DM set to +2 days (I don’t know if this is available since I don’t yet own Gravity Perks) — will this Limit Date functionality correctly set the following Monday as the earliest date that can be selected?

    2. Can the DM be set (not displayed) conditionally? For instance, based on my example above, I offer a 1-business day turnaround for a project if the customer checks the box for the ‘1-business day completion’ add on for the product they buy. Using the example above, if the customer fills out the form on Thursday, can I set the DM to be Current Date +1 day meaning Friday would be the Minimum Date they could select? Likewise, if the customer fills out the form on Friday, then the Minimum Date they could select would be Monday?

    I hope all that makes sense.

    Thanks, David!

    Jeff

    Reply
    1. David Smith
      David Smith Staff March 30, 2017 at 9:20 pm

      Hi Jeff,

      1. We have a copy-and-paste snippet that makes GP Limit Dates work this way. Just copy-and-paste into your theme’s functions.php and you’re good to go (once you’ve configured GP Limit Dates).
      2. The modifier currently cannot be conditional; however, you can create multiple Date fields, each configured with a possible modifier, and show/hide each field based on the which option is checked so that only the appropriate date range is selectable.
    2. Joshua Jenkins
      Joshua Jenkins November 8, 2018 at 1:59 pm

      Is the snippet to exclude weekend days from the minimum date as a previous poster referenced still available? The link gives a 404 and I can’t seem to find the gist on your account. Any help would be much appreciated! Thanks :)

    3. Joshua Jenkins
      Joshua Jenkins November 9, 2018 at 11:19 am

      Thanks David! You’re the best! I’ve installed and configured everything I think for the snippet to work – however the javascript doesn’t seem to be disabling those dates as intended – https://web.saumag.edu/communications/test-survvey/. This form sets the minimum date as current + 4 days, with Saturdays and Sundays disabled. You can see the script is being printed, but the extend modifiers filter doesn’t appear to be adding the weekend days as it should?

      Any help is very much appreciated :)

  6. Nick Gleed
    Nick Gleed February 20, 2017 at 7:24 am

    how could I enable days to be only selectable based on a value. For example the customer can choose a flight from “Acme Industries”, and the dates available are only on Monday & Thursday. But if they choose say flight from somewhere else it shows only dates on a Tuesday.

    Currently I have this set up as 2 depart dates one for each destination and displayed on conditional logic – which causes lots of problems.

    Reply
    1. David Smith
      David Smith Staff February 20, 2017 at 7:29 am

      This would require custom code to account for. The way you are handling it is the only way to do it out of the box. What kinds of issues are you running into?

    2. Nick Gleed
      Nick Gleed February 20, 2017 at 8:02 am

      The dates are set as required/mandatory – when I submit the form it goes back to page where dates are located they become blank …… or there is a conflict with the hidden dates. And annoying the date picker is read-only and the date picker disappears.

      Could you point me in the direction of how to add custom code into it? I accept that this would be non-supported etc but would like to know how to add this functionality to this or other aspects of GF perks.

      Cheers

    3. David Smith
      David Smith Staff February 20, 2017 at 8:25 am

      Your best bet is probably this filter:

      https://www.gravityhelp.com/documentation/article/gform_datepicker_options_pre_init/

      It’s the same one GP Limit Dates uses to integrate with Gravity Forms. You can use it to override GP Limit Dates integration as well.

      It sounds like the issues are you experiencing would be easier to solve than writing this custom functionality. If you want to send me a new ticket via the support form and include an export of your form with the date fields configured with this issue intact, I’ll be happy to take a look.

  7. Natascha
    Natascha July 13, 2015 at 3:20 am

    Hi David Thank you very much for this new perk. If tried to install the perk but I would get this message upon installing: Unable to find End of Central Dir Record signature

    Any ideas what that could be?

    Best, Natascha

    Reply
    1. Natascha
      Natascha July 14, 2015 at 11:12 am

      Hi David, thanks. I was able to install it. But now the perk ‘GP Limit Dates’ requires GF 1.9.11.10. I have a running subscription so I update regularly and I am currently on version 1.9.11. Which is the most current one available in the download section (just checked on GF page).

      Any idea? Or do you know if a new update is due? Thanks

    2. David Smith
      David Smith Staff July 14, 2015 at 11:39 am

      Hi Natascha, you should be seeing 1.9.11.14 on the download page. Could you check again? And sorry for the confusion, I should add a note to the documentation.

    3. Natascha
      Natascha July 14, 2015 at 5:11 pm

      Hi David, coool! It works! Another thing for the future: it would be nice to connect date conditions with time conditions. E.g. consultations on Fridays only from 07.00 to 11.00 and Saturdays from 13.00 to 17.00, and so forth :-D

      That would make Gravity Wiz’ Perks an option for all people who offer time slots, e.g. coaches, dog sitters, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Grab a bundle of free Gravity Forms plugins

Enter your email and receive our most popular free plugins and snippets, plus access to hundreds of others.

This field is for validation purposes and should be left unchanged.