How to limit dates to weekdays or weekends with Gravity Forms
Limit dates to weekdays, weekends or any other group of days.
Steps
- Install GP Limit Dates.
- Add a Date field to your form.
- Limit dates to Weekdays
- 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 47 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.
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.
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.
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.
Hi Patrick,
GP Limit Dates supports the
weekday
modifier for relative days. This should do the trick:+3 weekdays
.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
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,
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
Hi Hans, I think we do have the pieces you need. Drop us a line via our pre-sales form and we’ll be happy to lay out a plan of attack.
https://gravitywiz.com/have-a-question-about-gravity-perks/
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
Hey Jeff, not seeing those errors on my end but drop us a line on the support form with an export of your form and we’ll be happy to dig in. :)
https://gravitywiz.com/support/
Hi David,
Can you answer a few pre-sale questions about the Date Modifier?
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?
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
Hi Jeff,
Excellent news, David. Thanks! I’ll purchase right away.
Jeff
Excited to have you as a Gravity Perks user!
I’m needing to extend GP Limit Dates in this same manner (accounting for non-business days as part of minimum date) but the link above – https://gist.github.com/spivurno/85d1a9433af96667bd197332c98af042 – seems to no longer be valid. I scanned through your gists and just can’t seem to find the snippet anymore. Is this still doable? Thanks so much!
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 :)
Updated URL: https://gist.github.com/spivurno/6922e5e30744a3790b99dfab870a6cfa
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 :)
We’ll be happy to help you via the support form. ?
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.
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?
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
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.
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
Hi Natascha, we’ve fixed this issue. You should be good to go.
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
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.
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.
Definitely on the radar, Natascha. Thanks for the feedback! :)