Restrict Dates to Future Only in Gravity Forms Datepicker

/Restrict Dates to Future Only in Gravity Forms Datepicker

Gravity Forms is quite possibly the best forms plugin available for WordPress, but even with the vast array of functionality it offers right out of the box it still has its limitations.

One such limitation is the date picker field, offers practically no chance of configuration.

Recently a client asked to have their date picker so it would only select dates in the future, and while Gravity Forms has no way of doing this, fortunately there’s an easy jQuery fix, since Gravity forms uses jQuery standard date picker.

Simply add the following script code to your page/page template before where the form appears, substituting the #input_1_10 part with the form field ID of the datepicker field ID on your form.

<script type=”text/javascript”>
jQuery(document).ready(function($) {
$( “#input_1_10” ).datepicker({ minDate: ‘+0d’ });

To set the form to select dates that appear further in the future or perhaps only a week previous, change the +0d (plus zero days) part to something suited to your particular requirements (i.e. +14d to only allow dates two weeks in the future).

2018-11-07T01:05:46+00:00July 12th, 2017|WordPress Snippets|0 Comments

About the Author:

Warren Chandler is a freelance web programmer and web developer, based in Frinton on Sea, Essex. Warren specialises in web programming, web design, corporate identity, copy writing, SEO, logo and print media for home, work, and mobile platforms.

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.