Let’s say I have a form like this
I want 3 cases to happen upon form submission
Device Type = Apple & redirect <= 5
action → redirect to 1st url
Device Type = Android & redirect <= 5
action → redirect to 2nd url
Any other combination of Device Type and redirect
submit to pardot form handler
I want to ensure that all form data is captured in Unbounce as well
This is the script i came up with based on various other community posts, I have the form setting to post to pardot handler by defaut
<script>
<script>
window.ub.hooks.beforeFormSubmit.push(function() {
var number = args.formElement.querySelector('#redirect').val();
var units = parseInt(number);
var device = args.formElement.querySelector('#device_type').val();
console.log(number);
console.log(units);
console.log(device);
});
window.ub.hooks.afterFormSubmit.push(function(){
if(isNaN(units)){
alert("not a valid number");
}
else if( device ==='Apple' && units <= 5){
window.location.href = "https://www.apple.com";
}
else if( device ==='Android' && units <=5){
window.location.href = "https://www.google.com";
}
else{
}
});
</script>
doesn’t even come close to working… any help would be appreciated 🙂