CMS Development

YChuskit
Participant | Elite Partner
Participant | Elite Partner

Clear Hubspot form fields once clicked on submit button

SOLVE

Hello all,

so i have one modal button(inquiry form button): onclick inquiry form is displayed; i am using hubspot form. 
what i want is once i click on submit button thank you message should be diplayed  at the same time that form should be reset to blank form .can i achieve that? so that when user go and click on that modal button again they can enter another inquiry. but right now once the form is filled i can see thank you message every time i click on the modal button. the form gets reset only after i refresh the page.

i tried:- 

hbspt.forms.create({
portalId: ‘2333626’,
formId: ‘9a3ba836-f31f-4869-8d28-d264cc4259a8’,
onFormSubmit: function($form) {
$form[0].reset();
}

but i am getting error

0 Upvotes
2 Accepted solutions
Brownstephen101
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Clear Hubspot form fields once clicked on submit button

SOLVE

I don't believe you can do this with a Hubspot form. A workaround would be to have an html form display in place of the hubspot form, and use a serverless function to submit the data that you would like to submit via the api. Then you can use javascript to clear the fields or do whatever else you need to do. Hope this helps.

View solution in original post

webdew
Solution
Guide | Diamond Partner
Guide | Diamond Partner

Clear Hubspot form fields once clicked on submit button

SOLVE

Hi @YChuskit ,

I don't think this is possible with Hubspot forms, but this is possible with JavaScript/ajax with HTML forms.

Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.

View solution in original post

5 Replies 5
webdew
Solution
Guide | Diamond Partner
Guide | Diamond Partner

Clear Hubspot form fields once clicked on submit button

SOLVE

Hi @YChuskit ,

I don't think this is possible with Hubspot forms, but this is possible with JavaScript/ajax with HTML forms.

Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.

YChuskit
Participant | Elite Partner
Participant | Elite Partner

Clear Hubspot form fields once clicked on submit button

SOLVE

@webdew thank you i will try that out 

Brownstephen101
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Clear Hubspot form fields once clicked on submit button

SOLVE

I don't believe you can do this with a Hubspot form. A workaround would be to have an html form display in place of the hubspot form, and use a serverless function to submit the data that you would like to submit via the api. Then you can use javascript to clear the fields or do whatever else you need to do. Hope this helps.

YChuskit
Participant | Elite Partner
Participant | Elite Partner

Clear Hubspot form fields once clicked on submit button

SOLVE

thank you @Brownstephen101  for quick reply , i will try html form 

0 Upvotes
SCustomerCare
Member

Clear Hubspot form fields once clicked on submit button

SOLVE

While you're in the Options section of the form, enable the "Always create contact for new email address" option. This should automatically disable "Pre-populate contact fields with known values" as well. Now when the page reloads, the form should be empty and create a new contact instead of updating the same contact in its place.

 

More on these options here: https://knowledge.hubspot.com/forms/create-forms#customize-your-form-options

0 Upvotes