# Close a div on form validation - Webflow + Hubspot

**URL:** <https://community.hubspot.com/t/close-a-div-on-form-validation-webflow-hubspot/17672>\
**Category:** CMS Development\
**Tags:** javascript\
**Created:** [December 12, 2019, 12:44am UTC](https://community.hubspot.com/t/close-a-div-on-form-validation-webflow-hubspot/17672 "2019-12-12T00:44:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SpacedUp](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/spacedup/32/13521_2.png) [@SpacedUp](https://community.hubspot.com/u/SpacedUp)\
**Post date:** [December 12, 2019, 12:44am UTC](https://community.hubspot.com/t/close-a-div-on-form-validation-webflow-hubspot/17672/1 "2019-12-12T00:44:34Z")

</div>

Hi all,

I’ve been building in Webflow and have a Hubspot form inside a div (let’s call it, ‘Overlay-div’) which is gating the content on the page.

I would like the ‘Overlay-div’ to hide once the form is successfully validated. I’m guessing I need to use some sort of Javascript but I’m a little lost.

Does anyone have any experience with this?

I’ve consulted StackOverflow to find some related Javascript but implementation is really confusing me at the moment.

Existing code:

```auto
<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
 hbspt.forms.create({
portalId: "[PORTALID]",
formId: "[FORMID]"
});
</script>

```

(I’ve replaced my portalId and formId with placeholders)

Thanks

Paul

---

<div class="post-metadata">

**Author:** ![tjoyce](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tjoyce/32/88832_2.png) [@tjoyce](https://community.hubspot.com/u/tjoyce)\
**Post date:** [December 12, 2019, 12:29pm UTC](https://community.hubspot.com/t/close-a-div-on-form-validation-webflow-hubspot/17672/2 "2019-12-12T12:29:22Z")

</div>

```auto
<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
 hbspt.forms.create({
portalId: "[PORTALID]",
formId: "[FORMID]",onFormSubmit: function(){ $('.Overlay-div').hide();}
});
</script>

```

[https://developers.hubspot.com/docs/methods/forms/advanced\_form\_options](https://developers.hubspot.com/docs/methods/forms/advanced_form_options)

---

<div class="post-metadata">

**Author:** ![SpacedUp](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/spacedup/32/13521_2.png) [@SpacedUp](https://community.hubspot.com/u/SpacedUp)\
**Post date:** [December 12, 2019, 1:18pm UTC](https://community.hubspot.com/t/close-a-div-on-form-validation-webflow-hubspot/17672/3 "2019-12-12T13:18:02Z")

</div>

Ah, I was so close to this solution, thank you so much for the assistance.

Much appreciated 🙂
