# Javascript with Hubspot forms

**URL:** <https://community.hubspot.com/t/javascript-with-hubspot-forms/116740>\
**Category:** CMS Development\
**Tags:** forms\
**Created:** [September 20, 2024, 9:29am UTC](https://community.hubspot.com/t/javascript-with-hubspot-forms/116740 "2024-09-20T09:29:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CLahnsteiner](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@CLahnsteiner](https://community.hubspot.com/u/CLahnsteiner)\
**Post date:** [September 20, 2024, 9:29am UTC](https://community.hubspot.com/t/javascript-with-hubspot-forms/116740/1 "2024-09-20T09:29:27Z")

</div>

Hi!

I added a hubspot form with two input fields (email and code). After pressing a button, a small JavaScript file should be executed that generates a URL using the input values (e.g. [Example Domain](https://example.com?email=%7Bentered%5C_email%7D&code=%7Bentered%5C_code%7D)) and should redirect the user to this generated URL. Any ideas how I can aAdd a javascipt file to that form?

Many thanks,

Cornelia

---

<div class="post-metadata">

**Author:** ![AddaxLab](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/addaxlab/32/26380_2.png) [@AddaxLab](https://community.hubspot.com/u/AddaxLab)\
**Post date:** [September 20, 2024, 1:02pm UTC](https://community.hubspot.com/t/javascript-with-hubspot-forms/116740/2 "2024-09-20T13:02:14Z")

</div>

You can add automation after the form is submitted (and a contact is created). In this new workflow, you can send a webhook to your URL. Here, you can choose the request method (GET or POST) and add the needed fields from the new contact.  
But, as I right remember, you should have OperationalHub for that.

 ![AddaxLab_0-1726836849150.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/2/0/20465a3bdc62f3be1e62abae6a87b734f5358596.png)

 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/f/5/f58ff170094d5d63ea7854b044ec85538f107044.png)

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [September 20, 2024, 7:57pm UTC](https://community.hubspot.com/t/javascript-with-hubspot-forms/116740/3 "2024-09-20T19:57:58Z")

</div>

Hi @CLahnsteiner ,

You could [customize the embed form](https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options) where you can write your logic in the `onFormSubmit` event. That way, you can capture the input values and write a simple script to redirect the user to a new page. Make sure to use an inline thank you message for the form to prevent the user being redirected by HubSpot.

Here is a great example from another post: [https://community.hubspot.com/t5/Tips-Tricks-Best-Practices/Form-redirect-based-on-property-selection/m-p/522732](https://community.hubspot.com/t5/Tips-Tricks-Best-Practices/Form-redirect-based-on-property-selection/m-p/522732)  
However, if you have content or marketing Hub Pro, there is also a beta available that might allow you to set this up without having to code this: [Create and customize forms](https://knowledge.hubspot.com/forms/create-and-edit-forms-using-the-new-form-editor)
