Forked from R-A-M/webmail_valiation_free_and_anonymous.html
Last active
April 10, 2019 10:42
-
-
Save reatlat/0834f0ec9ca14fc6bc19ce2215003627 to your computer and use it in GitHub Desktop.
UnBounce deny free email domains
This file contains 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 characters
<script type="text/javascript"> | |
// Original idea taken here | |
// @link https://community.unbounce.com/t/require-business-email-address/14158 | |
(function () { | |
// set interval to check if jQuery loaded | |
var int_jQuery = setInterval(function () { | |
// add additional metood for check free emails | |
if (typeof lp.jQuery === "function") { | |
// clear interval for jQuery becoase lp.jQuery already loaded | |
clearInterval(int_jQuery); | |
// set Interval to check form is loaded or not | |
var int_rules = setInterval(function () { | |
if (typeof module.lp.form.data.validationRules === "object") { | |
// clear interval becoase form already have validation rules | |
clearInterval(int_rules); | |
// Optionally change this to customize the validation error that your visitors will see if they enter a webmail address. | |
//var message = 'Please enter your work mail address.'; | |
var message = 'Por favor ingrese su dirección de correo de trabajo.'; | |
// Replace 'email' with the actual ID of your form field. | |
var rules = module.lp.form.data.validationRules['email']; | |
lp.jQuery.validator.addMethod('notWebmail', function (value, field) { | |
var valid = /\@(?!(me|mac|icloud|gmail|googlemail|hotmail|live|msn|outlook|yahoo|ymail|aol)\.)/.test(value.toLowerCase()); | |
return valid || (!rules.required && !value); | |
}, message); | |
rules.notWebmail = true; | |
// fallback override validation rules | |
lp.jQuery('form').validate().settings.rules['email'] = rules; | |
} | |
}, 500); | |
} | |
}, 1000); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment