# Programmatically form redirect without jQuery (onFormSubmit)

**URL:** <https://community.hubspot.com/t/programmatically-form-redirect-without-jquery-onformsubmit/23869>\
**Category:** CMS Development\
**Created:** [August 6, 2020, 3:42pm UTC](https://community.hubspot.com/t/programmatically-form-redirect-without-jquery-onformsubmit/23869 "2020-08-06T15:42:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ballonura](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ballonura/32/77019_2.png) [@ballonura](https://community.hubspot.com/u/ballonura)\
**Post date:** [August 6, 2020, 3:42pm UTC](https://community.hubspot.com/t/programmatically-form-redirect-without-jquery-onformsubmit/23869/1 "2020-08-06T15:42:31Z")

</div>

There is anyway to do programmatically redirect the same form across multiple pages without require jQuery lib?

Like this solution just without jQuery:

[https://community.hubspot.com/t5/Content-Strategy-SEO/Creating-a-download-or-e-book-download/td-p/35430](https://community.hubspot.com/t5/Content-Strategy-SEO/Creating-a-download-or-e-book-download/td-p/35430)

---

<div class="post-metadata">

**Author:** ![sharonlicari](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sharonlicari/32/101479_2.png) [@sharonlicari](https://community.hubspot.com/u/sharonlicari)\
**Post date:** [August 10, 2020, 2:58pm UTC](https://community.hubspot.com/t/programmatically-form-redirect-without-jquery-onformsubmit/23869/2 "2020-08-10T14:58:57Z")

</div>

Hey @ballonura

thank you for sharing this. I’ll tag a few experts that could help you.

Hey @stefen @SandyG1 @Jsum any thoughts you can share with @ballonura?

Thanks

Sharon

---

<div class="post-metadata">

**Author:** ![ballonura](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ballonura/32/77019_2.png) [@ballonura](https://community.hubspot.com/u/ballonura)\
**Post date:** [August 10, 2020, 6:41pm UTC](https://community.hubspot.com/t/programmatically-form-redirect-without-jquery-onformsubmit/23869/3 "2020-08-10T18:41:22Z")

</div>

Thx @sharonlicari , i’ll w8.  
 ![16x16_smiley-very-happy.png.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/a/a83ec960612094a57cfb392e21c202c8e77b967c.png)

---

<div class="post-metadata">

**Author:** ![stefen](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stefen/32/29274_2.png) [@stefen](https://community.hubspot.com/u/stefen)\
**Post date:** [August 13, 2020, 2:04pm UTC](https://community.hubspot.com/t/programmatically-form-redirect-without-jquery-onformsubmit/23869/4 "2020-08-13T14:04:48Z")

</div>

@ballonura sure, you can use vanilla js to programatically redirect a user to a new page. Here’s an example that checks if the user submitted the form with a phone number and redirects to different pages depending on that:

```lia-code-sample
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
hbspt.forms.create({
portalId: "xxxxx",
formId: "xxx-xxx-xxx",
onFormSubmit: function() {
 var phone = document.querySelector('[name="tel"]').value;
 if(phone) {
 window.location.href = "http://exammple.com/ty-we-will-call-you";
 } else {
 window.location.href = "http://exammple.com/ty-we-will-email-you";
 }
 }
});
</script>

```
