How to require a future or past date with Gravity Forms Date Picker

Require dates to be greater than or less than current date (a.k.a. future or past dates).

Steps

Step 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.

Step 2 – Add a Date field to your form.

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

Step 3 – Future Dates: Set “Minimum Date” to Current Date.

Set the “Minimum Date” select to Current Date to require a date that is greater than or equal to today. This will automatically adjust to the current date each day.

Set Range from Current Date

If you’d like the date to be further in the future (i.e. one week from the current date), you can use the “Date Modifier” input to specify the range from the current date that should be required.

Step 4 – Past Dates: Set “Maximum Date” to Current Date.

Set the “Maximum Date” select to Current Date to require a date that is less than or equal to today. This will automatically adjust to the current date each day.

Comments

  1. Richard
    Richard April 19, 2022 at 8:21 am

    It would be fantastic if this worked with non-picker date types, what is the reason it doesn’t work with the date field type?

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff April 19, 2022 at 8:58 am

      Hi Richard,

      The GP Limit Dates Perk was designed for the Datepicker and currently doesn’t support the other Date field type. We hope to add support for it in the future.

      Best,

    1. Samuel Bassah
      Samuel Bassah Staff August 27, 2020 at 8:48 am

      Hi Joel,

      This already works with Custom Field of Date Type. The GP Limit Dates Perks Tab will display on the custom field if you change the Field Type to Date and you can set it up just as you want.

      Best,

  2. Edward
    Edward February 9, 2020 at 10:35 am

    Hey David, I’ve set up the date picker so that Sundays are the only days available. I want to have users be able to select a Sunday following the previous Friday. I can’t seem to configure it the way I’d like. Somehow, it’s still showing the Sunday available following on the Saturday before and when the current day is Sunday, the current Sunday is available. (if that makes sense).

    How can I set it up to have the user select the Sunday following the day of the week of Friday or before?

    Reply
  3. Luke Cavanagh
    Luke Cavanagh April 27, 2016 at 3:10 pm

    Would there be a way to use this to be able to set a date limit from a previous date field. So the value in the to field could not be greater than today or greater than the value in the from field?

    Thanks in advance.

    Gravity Perks rocks!

    Cheers Luke

    Reply
  4. Andrew
    Andrew August 5, 2015 at 3:15 pm

    David et al., Thanks for creating this perk. Just wanted to let you know that the perk helped streamline one of our forms. I managed to scrap some jQuery together to do something similar. This perk is much more streamlined.

    This is what it helped get rid of:

    <!– var holidays = [“2/17/2015”, “3/17/2015”, “3/19/2015”]; jQuery(“#input_37_9”).datepicker({ minDate: 2, maxDate: new Date(2015, 4, 21), beforeShowDay: function(e) { show = !0, 2 != e.getDay() && (show = !1); for (var a = 0; a < holidays.length; a++) new Date(holidays[a]).toString() == e.toString() && (show = !1); var n = [show, "", show ? "" : "Please only select a Tuesday."]; return n } }), jQuery("#input_37_10").datepicker({ minDate: 2, maxDate: new Date(2015, 4, 21), beforeShowDay: function(e) { show = !0, 4 != e.getDay() && (show = !1); for (var a = 0; a < holidays.length; a++) new Date(holidays[a]).toString() == e.toString() && (show = !1); var n = [show, "", show ? "" : "Please only select a Thursday."]; return n } }); –>

    Thank you guys so much. Awesome work.

    Reply
    1. David Smith
      David Smith Staff August 7, 2015 at 9:21 am

      Thanks for sharing, Andrew! I had been doing a lot of this same stuff over and over again in my own work so I decided to streamline the process a bit. Glad it saved you some hassle as well. :)

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.