Redirecting a HubSpot form to a thank you page based on a form field

I’m trying to configure a HubSpot form to redirect to a URL if a field is checked. I also want the same form to redirect to a different URL if the field is unchecked.

How would I make the redirectURL into a conditional statement based on whether or not a box is checked?

Tried a few options but now out of ideas. At one stage I got it to redirect, but wouldn’t pick up any form submissions via Safari.

Failed attempt below.

<!--[if lte IE 8]>

<script charset=“utf-8” type=“text/javascript” src=“//js.hsforms.net/forms/v2-legacy.js”></script>

<![endif]--><script charset=“utf-8” type=“text/javascript” src=“//js.hsforms.net/forms/v2.js”></script><script>

hbspt.forms.create({

portalId: “*******”,

formId: ************",

onFormSubmitted: function($form) {

if($form.find(‘input[name=“property name”]’).prop(‘checked’)){

window.location.href = “URL 1”;

}else{

window.location.href = “URL2”;

}

}

});

</script>

Hi @RMaradan, I found this article which describes the how-to for exactly what you are trying to do. Stephanie O’Gay Garcia uses the Form Event Listener to accomplish the thank you page redirecting based on a form field.

Here is the link to the article: Redirect a HubSpot form to a thank you page based on a form field

The article shares the code to use along with screenshots in HubSpot of how to make the form field the unique identifier.

Hey! Thanks for sharing.

The article got me about 9/10ths of the way there, the main stumbling block is that article is for dropdown vs checkbox - and I have thus far struglged to get it to replicate perfectly using the checkbox functionality.

Note that the solution in the article is only available for marketing / cms hub professional and enterprise