Page refresh after button submit



Hi I am trying to find a solution for a form on a Hubspot page (not embedded) where after the button submission an inline “thank you” message appears and then after 5-10 seconds the page reloads to original page with blank form.

The use of the form is for a front desk sign in so I am trying to avoid having to manually reset the page after display of the in-line “TY”. Currently I have the form redirecting to the original landing page so after submission the page reloads but the user doesn’t get a visual cue that anything was submitted…

Looking to add something like below snippet to my form script.


Where would I add this as I am not embedding the form? Or more importantly… how can I accomplish the refresh after buttonSubmit?

Below is the default format of the embed code… I am thinking I can create a page outside of Hubspot and add the snippet of code above to the section labeled YOUR SCRIPT HERE but checking to see if there is a better solution.

hbspt.forms.create({ portalId: '', formId: '', onFormSubmit: function($form) { // YOUR SCRIPT HERE } });

Any help is greatly appreciated! (P.S. I am not very well versed in JS so I apologize in advance for the noob factor :stuck_out_tongue_winking_eye: )


You could use the form embed code you have there with the reload code you mentioned, how ever reloading the page will not get rid of the inline ty message, since the url changes ( thats how it tells if it should be displaying the ty message ). but you could do a delayed redirect in the same way. Also the embed code doesn’t necessarily need to be on a page outside of hubspot, you can place it on a hubspot page as well.


Thx for your reply. I didn’t get exactly that to work but found a solution.


@johnK could you post the solution that worked for you?


Yes my bad for not posting my solution. So I have a sign in page hosted on Hubspot (w3w.blah/sign_in_page) and I embedded the form into that page using an HTML module.
I have the form set to redirect to itself, essentially reloading the page URL. But to show the user that their submission was successful I added an alert at the end of the form embed script. Before the page redirects back to itself (reloading the form) the user must click ok in the alert box. Kinda a work around but it works.

portalId: '2------4',
formId: 'fslkdfjh------d',
onFormSubmit: function ($form) {
alert('Thank You for signing in.');