Hello,
I found the script below in this discussion: How do I require a BUSINESS email
I pasted the script in my Marketo landing page template and tested the form with a Yahoo email address and it still is allowing me to submit the form. Where exactly should this script be placed to reject non-business email addresses for particular forms? Any help would be greatly appreciated.
| <script> | |
| (function (){ | |
| // Please include the email domains you would like to block in this list | |
| var invalidDomains = ["@yahoo.","@hotmail.","@live.","@aol.","@msn.","@outlook."]; | |
| MktoForms2.whenReady(function (form){ | |
| form.onValidate(function(){ | |
| var email = form.vals().Email; | |
| if(email){ | |
| if(!isEmailGood(email)) { | |
| form.submitable(false); | |
| var emailElem = form.getFormElem().find("#Email"); | |
| form.showErrorMessage("Must be Business email.", emailElem); | |
| }else{ | |
| form.submitable(true); | |
| } | |
| } | |
| }); | |
| }); | |
| function isEmailGood(email) { | |
| for(var i=0; i < invalidDomains.length; i++) { | |
| var domain = invalidDomains[i]; | |
| if (email.indexOf(domain) != -1) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } | |
| })(); | |
| </script> |
Thanks!
Trevor
Solved! Go to Solution.
Lawdy, how I hate that code. ![]()
It should have barebones functionality, though. Are you being sure to include it after the <script> that loads forms2.min.js? On a Marketo LP, you'll want to put this just inside the closing </body> tag (because Mkto may inject the forms2.min.js at any point in the body content).