# HTML Block Not Working

**URL:** <https://community.gravityforms.com/t/html-block-not-working/1829>\
**Category:** Get Help\
**Tags:** gravity-wiz, datepicker\
**Created:** [May 11, 2019, 9:01pm UTC](https://community.gravityforms.com/t/html-block-not-working/1829 "2019-05-11T21:01:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![user5b9c6e950381d6.1](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@user5b9c6e950381d6.1](https://community.gravityforms.com/u/user5b9c6e950381d6.1)\
**Post date:** [May 11, 2019, 9:01pm UTC](https://community.gravityforms.com/t/html-block-not-working/1829/1 "2019-05-11T21:01:56Z")

</div>

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;
} );
</script>

```

All help is appreciated!

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [May 12, 2019, 11:06am UTC](https://community.gravityforms.com/t/html-block-not-working/1829/2 "2019-05-12T11:06:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Parkbum](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/parkbum/32/810_2.png) [@Parkbum](https://community.gravityforms.com/u/Parkbum)\
**Post date:** [May 12, 2019, 12:50pm UTC](https://community.gravityforms.com/t/html-block-not-working/1829/3 "2019-05-12T12:50:03Z")

</div>

> [@user5b9c6e950381d6.1](#):
>
> ML block stopped working, and now clients can select any date instead of it being restricted to only the

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

```
 $('#field_2_36').hide();
 $('#input_2_36').attr('disabled');

```

---

<div class="post-metadata">

**Author:** ![user5b9c6e950381d6.1](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@user5b9c6e950381d6.1](https://community.gravityforms.com/u/user5b9c6e950381d6.1)\
**Post date:** [May 12, 2019, 1:23pm UTC](https://community.gravityforms.com/t/html-block-not-working/1829/4 "2019-05-12T13:23:28Z")

</div>

> [@Parkbum](#):
>
> and now clients can select any date instead of it being restricted to only the

The URL is:

[https://jglaundromat.com/schedule-pick-up/](https://jglaundromat.com/schedule-pick-up/)

---

<div class="post-metadata">

**Author:** ![Parkbum](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/parkbum/32/810_2.png) [@Parkbum](https://community.gravityforms.com/u/Parkbum)\
**Post date:** [May 12, 2019, 1:46pm UTC](https://community.gravityforms.com/t/html-block-not-working/1829/5 "2019-05-12T13:46:51Z")

</div>

Ah, sorry 7 am here 🙂 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.

---

<div class="post-metadata">

**Author:** ![user5b9c6e950381d6.1](https://avatars.discourse-cdn.com/v4/letter/u/dec6dc/32.png) [@user5b9c6e950381d6.1](https://community.gravityforms.com/u/user5b9c6e950381d6.1)\
**Post date:** [May 16, 2019, 12:19am UTC](https://community.gravityforms.com/t/html-block-not-working/1829/6 "2019-05-16T00:19:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Parkbum](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/parkbum/32/810_2.png) [@Parkbum](https://community.gravityforms.com/u/Parkbum)\
**Post date:** [May 16, 2019, 4:05pm UTC](https://community.gravityforms.com/t/html-block-not-working/1829/7 "2019-05-16T16:05:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![david](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/david/32/2517_2.png) [@david](https://community.gravityforms.com/u/david)\
**Post date:** [May 17, 2019, 12:17pm UTC](https://community.gravityforms.com/t/html-block-not-working/1829/8 "2019-05-17T12:17:37Z")

</div>

I’d recommend using my [Gravity Forms Limit Dates](https://gravitywiz.com/documentation/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.

---

<div class="post-metadata">

**Author:** ![richardw8k](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/richardw8k/32/2354_2.png) [@richardw8k](https://community.gravityforms.com/u/richardw8k)\
**Post date:** [January 4, 2022, 5:25pm UTC](https://community.gravityforms.com/t/html-block-not-working/1829/9 "2022-01-04T17:25:29Z")

</div>

Closed on January 4, 2022, 5:25pm UTC


