Marketo Forms 2.0 Example 1

Hides the form after successful submission. Does not take the visitor to the follow up page or reload the current page.

by Victor Yap

HTML

<h2>Example 1</h2>
<p>Hides the form after successful submission.  Does not take the visitor to the follow up page or reload the current page.
</p>

<script src="//app-sjst.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_1057"></form>
<script>
	MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form){
		//Add an onSuccess handler
		form.onSuccess(function(values, followUpUrl){
			//get the form's jQuery element and hide it
			form.getFormElem().hide();
			//return false to prevent the submission handler from taking the lead to the follow up url.
			return false;
		});
	});
</script>