# Conditional Logic Redirect on Form Submission

**URL:** <https://community.hubspot.com/t/conditional-logic-redirect-on-form-submission/66815>\
**Category:** CMS Development\
**Tags:** professional\
**Created:** [October 10, 2022, 7:27pm UTC](https://community.hubspot.com/t/conditional-logic-redirect-on-form-submission/66815 "2022-10-10T19:27:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RBradford](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rbradford/32/196573_2.png) [@RBradford](https://community.hubspot.com/u/RBradford)\
**Post date:** [October 10, 2022, 7:27pm UTC](https://community.hubspot.com/t/conditional-logic-redirect-on-form-submission/66815/1 "2022-10-10T19:27:24Z")

</div>

So I know that there’s a ton of disussion around this already, but I’ve dived in and continueally run into issues getting it to actually work. Here’s what I have:

```lia-code-sample
script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script>
<script>
 hbspt.forms.create({
 region: "na1",
 portalId: "XXXXXXXX",
 formId: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
 onFormSubmit: function($form) {
var choice = $('input[name="accredited_investor"]:checked').val();
if (choice == 'Yes I qualify as an accredited investor') {
window.location = 'https://www.wefunder.com/atakama/invest?amount=10000';
} if (choice == 'No I do not qualify as an accredited investor'){
window.location = 'https://invest.atakama.com/sorry';
}
} 
}); 
</script>

```

Any Ideas? I’m really needing to get this working ASAP.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [October 11, 2022, 6:06pm UTC](https://community.hubspot.com/t/conditional-logic-redirect-on-form-submission/66815/2 "2022-10-11T18:06:36Z")

</div>

Hi, @RBradford 👋 Thanks for providing your example. Hey, @Teun @LeeBartelme, do you have any quick tips for @RBradford?

Thank you! — Jaycee

---

<div class="post-metadata">

**Author:** ![LeeBartelme](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leebartelme/32/95647_2.png) [@LeeBartelme](https://community.hubspot.com/u/LeeBartelme)\
**Post date:** [October 11, 2022, 6:12pm UTC](https://community.hubspot.com/t/conditional-logic-redirect-on-form-submission/66815/3 "2022-10-11T18:12:18Z")

</div>

[https://community.hubspot.com/t5/APIs-Integrations/Redirecting-Hubspot-form-to-different-urls-depending-on-property/td-p/692081](https://community.hubspot.com/t5/APIs-Integrations/Redirecting-Hubspot-form-to-different-urls-depending-on-property/td-p/692081)

You can’t reference the form fields directly. See my answer and the reason why. You must get the from the $form object.
