Hello All,
I'm using the Forms 2.0 builder for the first time and I'm running into some issues that I can't seem to resolve.
I need to enable custom validation on 2 different fields in my form, a 'password' field and a 'confirm password' field. I've gotten this working for the most part, but have run into 2 issues that I can't figure out.-
If the form is submitted and there is a validation error, my custom message is showing up as desired. But if I then fixed the error and submit the form again, the form does not submit correctly. The page seems to reload, but nothing happens (no JavaScript error either).
-
If the form is submitted with errors on both custom fields, an error message shows up on the first of the two. If I fix the first error and submit again, no error message shows up on the 2nd custom field. Instead again, the page seems to reload and does not submit.
I was using the sample code available on this link - http://developers.marketo.com/documentation/websites/forms-2-0/ - has anyone run into a similar issue as this? Below is my current JavaScript for the form embed:
<script src="//app-sjn.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_1373"></form>
<script>
//var theForm = document.getElementById("mktoForm_1373");
MktoForms2.loadForm("//app-sjn.marketo.com", "729-ZYH-434", 1373, function(form){
form.onSubmit(function(){
var vals = form.getValues();
if (vals.platformPassword.length < π {
form.submitable(false);
var platformPassword = form.getFormElem().find("#platformPassword");
form.showErrorMessage("Your password must be a minimum of 8 characters in length.", platformPassword);
} else if (vals.platformPasswordConfirm != vals.platformPassword) {
form.submitable(false);
var platformPasswordConfirm = form.getFormElem().find("#platformPasswordConfirm");
form.showErrorMessage("Your password confirmation does not match your password.", platformPasswordConfirm);
} else {
form.submitable(true);
}
});
});
</script>
I'm not getting a JavaScript error - it just doesn't work.
Thanks,
Ben