Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reatlat/0834f0ec9ca14fc6bc19ce2215003627 to your computer and use it in GitHub Desktop.
Save reatlat/0834f0ec9ca14fc6bc19ce2215003627 to your computer and use it in GitHub Desktop.
UnBounce deny free email domains
<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