I'm trying to implement custom validation on my embedded Marketo Form 2.0. We're strictly B2B and so I am wanting to add some additional validation to the Email field - to ensure they aren't using typical ISP/ free email accounts. I have tried setting the field type to String (rather than email) and setting/ emptying the Custom Validation message (I'd rather avoid this as the message will change according to logic in the javascript), but whatever I do the error message is not populated from my code:
form.onValidate(function(){
var vals = form.getValues();
if (jqff.inArray(vals.Email, invalidEmailDomains) > -1 ){
console.log("invalid email"); //triggers OK
form.submitable(false);
var TextField_Email = form.getFormElem().find("#Email");
console.log(TextField_Email); //gets the field OK
form.showErrorMessage("Custom error message here", TextField_Email);
}
TIA
Ben