Does anyone have a sample form validation script that will not allow numbers to be entered in the first or last name field?
Thanks,
Jason
Solved! Go to Solution.
Unfortunately, the example code has a bug (always has). It doesn't correctly check against built-in validation, which can end up being very confusing when writing custom validators.
Something more extensible: MktoForms2 :: Extended Validation from Validators Array
Hi Jason Hamilton
<script>
MktoForms2.loadForm("//app-ab99.marketo.com", "999-IBN-999", 9999, function (form) {
//listen for the validate event
form.onValidate(function() {
// Get the values
var vals = form.vals();
//Check your condition
if (vals.FirstName.match(/[0-9]+/) || vals.LastName.match(/[0-9]+/)) {
// Prevent form submission
form.submittable(false);
// Show error message, pointed at VehicleSize element
form.showErrorMessage("I don't like numbers!");
}
else {
// Enable submission for those who met the criteria
form.submittable(true);
}
});
});
</script>
http://developers.marketo.com/documentation/websites/forms-2-0/
This code is based on example 9
Unfortunately, the example code has a bug (always has). It doesn't correctly check against built-in validation, which can end up being very confusing when writing custom validators.
Something more extensible: MktoForms2 :: Extended Validation from Validators Array
Worked great as usual, thanks Sanford Whiteman
I have another question re integrating corporate email validation into this, but I will start a new string.