Conditional Return: false on Marketo Forms
I have the following custom form code that displays a thank you message on submit without reloading the page. I'd like to take this a step further and make this conditional. If the field C_Service_Reason is submitted with the value Training, then I don't want the thank you message to display, and instead want them to be redirected to an external URL on success.
Any help with this would be much appreciated, thank you!
<script ></script>
<form id="mktoForm_2338"></form>
<script>MktoForms2.loadForm("//app-sj04.marketo.com", "980-GBD-747", 2338);</script>
<script>
MktoForms2.whenReady(function (form){
//Add an onSuccess handler
form.onSuccess(function(values, followUpUrl){
dataLayer.push({
'event': 'contacttest',
'eventCallback' : function () {
form.getFormElem().hide();
document.getElementById('contacttest').style.visibility = 'visible';
}
});
return false;
});
})
</script>
<div id="contacttest" style="visibility:hidden; text-align: center;">Thank you for your interest! A Hatch expert will be in touch soon.</div>