Conditional Logic Redirect on Form Submission

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:

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.

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

Thank you! — Jaycee

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.