# hsvalidatedsubmit apparently preventing Contact creation

**URL:** <https://community.hubspot.com/t/hsvalidatedsubmit-apparently-preventing-contact-creation/35417>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [April 13, 2021, 10:05am UTC](https://community.hubspot.com/t/hsvalidatedsubmit-apparently-preventing-contact-creation/35417 "2021-04-13T10:05:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielelodola](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/danielelodola/32/77060_2.png) [@danielelodola](https://community.hubspot.com/u/danielelodola)\
**Post date:** [April 13, 2021, 10:05am UTC](https://community.hubspot.com/t/hsvalidatedsubmit-apparently-preventing-contact-creation/35417/1 "2021-04-13T10:05:15Z")

</div>

Hello All,

We use the “hsvalidatedsubmit” event in conjunction with a window.location.refresh call in order to display different thank-you pages, based on an option from the submitted form.

In some instances, I get the impression this custom redirect is preventing the creation of the Contact in the HubSpot account. Does this make sense at all? Has anyone experienced similar issues when using hsvalidatedsubmit?

```lia-code-sample
$('body').on('hsvalidatedsubmit', '.hs-form', function (e) {
 if ($(this).hasClass('#########')) {
 /*evaluate use case here */
 if something {
 window.location.href = "url1";
 }
 else if somethingelse {
 window.location.href = "url2";
 }
 };
 }

```

Also, is there a way to call a custom callback function once the hsvalidatedsubmit has completed successfully?

Thanks a bunch!

DL

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [April 13, 2021, 6:36pm UTC](https://community.hubspot.com/t/hsvalidatedsubmit-apparently-preventing-contact-creation/35417/2 "2021-04-13T18:36:50Z")

</div>

Hey @danielelodola , unsure if you have seen [this](https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options) forms doc before. There is a callback for **onformsubmitted** that might be of value.

@Kevin-C , what are your thoughts?

---

<div class="post-metadata">

**Author:** ![Kevin-C](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevin-c/32/34570_2.png) [@Kevin-C](https://community.hubspot.com/u/Kevin-C)\
**Post date:** [April 13, 2021, 7:41pm UTC](https://community.hubspot.com/t/hsvalidatedsubmit-apparently-preventing-contact-creation/35417/3 "2021-04-13T19:41:10Z")

</div>

Thanks @dennisedson

Hey @danielelodola

I believe Dennis is correct!

Using **onformsubmitted** will ensure that the coversion will resolve before the page redirects!

---

<div class="post-metadata">

**Author:** ![danielelodola](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/danielelodola/32/77060_2.png) [@danielelodola](https://community.hubspot.com/u/danielelodola)\
**Post date:** [April 14, 2021, 7:18am UTC](https://community.hubspot.com/t/hsvalidatedsubmit-apparently-preventing-contact-creation/35417/4 "2021-04-14T07:18:46Z")

</div>

Thanks @Kevin-C @dennisedson

Does the “onformsubmitted” method replace the “hsvalidatedsubmit” method? Does it ensure that the callback function(s) are only on triggered on **valid** form submissions?

This aspect is important for us, as we like to handle all conversion tracking at the valid form submission level.

Regards

DL

---

<div class="post-metadata">

**Author:** ![Kevin-C](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevin-c/32/34570_2.png) [@Kevin-C](https://community.hubspot.com/u/Kevin-C)\
**Post date:** [April 14, 2021, 12:50pm UTC](https://community.hubspot.com/t/hsvalidatedsubmit-apparently-preventing-contact-creation/35417/5 "2021-04-14T12:50:38Z")

</div>

Hey @danielelodola

"The hsvalidatedsubmit event is triggered after the data in a HubSpot form passes validation. You can detect when that event is triggered, but anything you do after detecting the event would not block the submission from proceeding.

The onFormSubmit function gets executed as part of the submission itself, so anything you include in that function will be executed before the form proceeds with the submission.

…

onFormSubmit is called after validation passes, right before the form data is actually sent to HubSpot, and if you can add onFormSubmit to the embed code it’s going to be a better solution than listening for the hsvalidatedsubmit event."

[From this post](https://community.hubspot.com/t5/APIs-Integrations/Is-the-forms-javascript-onFormSubmit-a-blocking-function/td-p/236994)

@Dadams could you lend a hand clarifying? I’m sure I’ve butchered something lol
