Disable past dates from datepicker

Hi,

I have found 2 snippets related to disable past dates from selecting past dates. Now I got the below script active at this page: Reserveren voor lunch of high tea | De Huiskamer van Driebergen

Unfortunately you still can select the past dates.
Do you know the correct script for this?

Cheers,
Niels

Hi Niels,

To disable the paste date, please try the following JavaScript code snippet.

gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
    // add your own field ID instead of 2
    if ( fieldId == 2 ) {
        optionsObj.minDate = 0;
    }
    return optionsObj;
});

How to find the field ID:

You can use the provided JS code snippet in your child theme’s JavaScript file or try the “Simple Custom CSS and JS” plugin.

Give it a try, and let me know how that goes! :smile:

1 Like

Gravity Wiz also offers a free plugin for adding form-specific scripts:

3 Likes

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