Since the most recent update with WordPress, I encountered an issue with my embedded HubSpot forms on my website. The form itself is still operable but as soon as you try to edit a WordPress page the form currently lives on, the form no longer functions. The code for the form remains in the source code when I check with the code inspector on the actual published page but the form itself just doesn’t show up. The spot on the published page where it should be remains blank.
When I do inspect the code within WordPress though, I notice that it adds breaks exactly like this <br /> to my embedded form’s code. I erase them and re-publish and nothing happens.
The entire code snippet is:
<div class=”newreg-form” style=”width: 70%; display: block;”><!– [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><br />
hbspt.forms.create({<br />
portalId: ‘386862’,<br />
formId: ‘2243bd40-1f0c-4429-aaed-35a29cfe5a02’,<br />
target: ‘.newreg-form'<br />
});<br />
</script></div>
<div>ONE STRING OF TEXT</div>script>/script>script>/script>script>/script>
@swansonphotos is right – those pesky BR tags are BReaking your JavaScript. By removing the spaces (as @swansonphotos suggested) your JavaScript should behave.
Before
<script><br />
hbspt.forms.create({<br />
portalId: ‘386862’,<br />
formId: ‘2243bd40-1f0c-4429-aaed-35a29cfe5a02’,<br />
target: ‘.newreg-form'<br />
});<br />
</script>
After
<script>hbspt.forms.create({portalId: '386862',formId: '2243bd40-1f0c-4429-aaed-35a29cfe5a02', target: '.newreg-form'});</script>
Also, I recommend you try the new HubSpot WordPress Plugin. It has a Shortcode which makes it easier to handle forms (and harder to break them).
Let me know if that works for you.
Cheers
Mike