1

I can't make an alert in JS when clicking on the "Submit" button. It's html loaded remotely by a script and the JS can't recognize it.

Here is a reconstruction, anyone have an idea please? http://jsfiddle.net/sdrvqjxn/1/

<script charset="utf-8" type="text/javascript" src="//js-eu1.hsforms.net/forms/embed/v2.js"></script>
<script>
  hbspt.forms.create({
    region: "eu1",
    portalId: "26927362",
    formId: "46123717-093e-4314-9afb-d71fc6e2e40f"
  });
</script>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Tayzzer
  • 21
  • 2

1 Answers1

1

Set the onFormSubmit option:

hbspt.forms.create({
    region: "eu1",
    portalId: "26927362",
    formId: "46123717-093e-4314-9afb-d71fc6e2e40f",
    onFormSubmit() {
        alert('submit');
    }
});
Unmitigated
  • 76,500
  • 11
  • 62
  • 80
  • Thanks, it works. do you know if in the same way I can alert the content of a form field? thanks in advance – Tayzzer Feb 05 '23 at 22:59