Note - The following code instructions are intended for usage with eTrigue standard forms and assumes you are working with out of the box form code. |
Caution: Please be careful when copying and pasting code. Be sure not to leave any characters out when replacing each section.
- On the webpage that contains the eTrigue form, look for the following code:
} else {
if (!_etgf.valid(_etgf.fldval('x_emailaddress'))) {
err.push('Email is invalid.');
red.push('x_emailaddress');
}
} - Replace the above with this:
} else {
if (!_etgf.valid(_etgf.fldval('x_emailaddress'))) {
err.push('Email is invalid.');
red.push('x_emailaddress');
}
if (_etgf.rejectDomains(_etgf.fldval('x_emailaddress'))) {
err.push('Domain not allowed.');
red.push('x_emailaddress');
}
} - Next, find this code:
valid: function(a) {
let b = /^([a-zA-Z0-9]+[a-zA-Z0-9_\-\.]*\@([a-zA-Z0-9]+[a-zA-Z0-9\_-]*\.)+[a-zA-Z0-9]+)$/;
return b.test(a) ? !0 : !1;
}
}; - And replace it with this:
valid: function(a) { let b = /^([a-zA-Z0-9]+[a-zA-Z0-9_\-\.]*\@([a-zA-Z0-9]+[a-zA-Z0-9\_-]*\.)+[a-zA-Z0-9]+)$/; return b.test(a) ? !0 : !1; },
rejectDomains: function(email) { let domainsArr = ["yahoo.com", "google.com"]; let domain = email.split("@")[1]; if (domainsArr.indexOf(domain) > -1) { return true; } } }; - In step 4, you can list which domains you want to block in the domainsARR variable.
Each domain should be separated with a comma and the domain should be inside two sets of double quotes.
For example, if you wanted to add "comcast.net" to the blocked list, the code line would look like this:
let domainsArr = ["yahoo.com", "google.com", "comcast.net"];