HTML Block Not Working

Hey guys!

I have several HTML blocks on a form, each dedicated to restrict available dates on its respective date picker.

All date pickers do not show at once, only one at a time depending on what time of the day it is.

For some reason the HTML block stopped working, and now clients can select any date instead of it being restricted to only the current date (0) or after.

I am using the following code:

<script type="text/javascript">
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 2 && fieldId == 36 ) {
optionsObj.minDate = '+1 D';
optionsObj.maxDate = '+2 W';
return optionsObj;
} );

All help is appreciated!

What is the url of the page where we can see your form?

For complicated conditionals I’d manually hide the fields with:


The URL is:

Ah, sorry 7 am here :slight_smile: coffee still kicking in.

Check out your console. It is throwing errors for the code itself, Uncaught ReferenceError: gform is not defined. I honestly don’t like using the HTML field for Scripts. Try using a plugin like Scripts n Styles instead of inserting custom Scripts into HTML blocks.

I tried using the plugin, but it still did not work, any other suggestions you think may work?

Sorry to hear, wouldn’t know what the issue is without really messing with it. Keep in mind you don’t need <script type="text/javascript"> tags in Scripts n Styles.

I’d recommend using my Gravity Forms Limit Dates plugin. It’s easy to configure, works well, requires no custom code, and will clean up your form by ditching all those HTML fields.

1 Like