Created
September 9, 2014 23:49
Revisions
-
MurtzaM created this gist
Sep 9, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ //This script prevents Marketo form submission if a user enters non-business email (Gmail, Hotmail, Yahoo, etc.) //It will work on any page with a Marketo form, and runs when the form is ready //For further info, please see Marketo form documentation, http://developers.marketo.com/documentation/websites/forms-2-0/ //Prepared by Ian Taylor and Murtza Manzur on 9/9/2014 <script> (function (){ // Please include the email domains you would like to block in this list var invalidDomains = ["@gmail.","@yahoo.","@hotmail.","@live.","@aol.","@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>