# Form submit with javascript

**URL:** <https://community.hubspot.com/t/form-submit-with-javascript/40658>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [July 13, 2021, 4:07pm UTC](https://community.hubspot.com/t/form-submit-with-javascript/40658 "2021-07-13T16:07:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsastre](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/bsastre/32/78108_2.png) [@bsastre](https://community.hubspot.com/u/bsastre)\
**Post date:** [July 13, 2021, 4:07pm UTC](https://community.hubspot.com/t/form-submit-with-javascript/40658/1 "2021-07-13T16:07:43Z")

</div>

Hi there!

I am using a non-hubspot contact form.

If I use document.getElementById(“myCustomForm”).submit(); on a separate javascript file, Hubspot does seem to process the data. In other words, I don’t get an email with the form submission.

I need to do document.getElementById(“myCustomForm”).submit(); because I am redirecting to another page with a long query string of data that I collect on a separate javascript file.

Any ideas how to make this work?

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [July 14, 2021, 9:51am UTC](https://community.hubspot.com/t/form-submit-with-javascript/40658/2 "2021-07-14T09:51:14Z")

</div>

Hi @bsastre ,  
Jquery code to reload this:  
\<script\>  
$(‘#\<formid\>’).submit();  
\</script\>  
But Please use HubSpot Forms API for storing form data and use the ajax with callback function from frontend and use serverless function or any other programming language. Make sure saves all needed information into form submissions list.  
Hope this will work for you.  
HubSpot form api Link : [https://legacydocs.hubspot.com/docs/methods/forms/submit\_form](https://legacydocs.hubspot.com/docs/methods/forms/submit_form)

Hope this helps!

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