Disallow edu and org email addresses

Hi, we have a few landing pages where we sometimes receive edu and org email addresses, I’d like to flag an error as we already do for Gmail and other free email services. Is there a javascript code I can add in addition to the one we already use?

LP example: https://sanfrancisco.bettsrecruiting.com/employer-form-a/

existing javascript:

  window.ub.form.validationRules.email.nonWebmailEmail = true;

  window.ub.form.customValidators.nonWebmailEmail = {
    isValid: function(value) {
      return /\@(?!(me|mac|icloud|gmail|googlemail|hotmail|live|msn|outlook|yahoo|ymail|aol|edu|)\.)/.test(value.toLowerCase());

    message: 'Please enter your work email address or see note below',

Hmmm, you definitely have the right regex in the script for gmail and other services @helmstetler

But if you want to block “.edu” and “.org” those characters come after the “@domain.” So the regex would have to change and it could get really complicated.

It would be easier to use a form title or the pre-fill text to specifically state the type of email required.

It’s certainly possible to use your current code with the additional changes you have in mind, but with its current implementation it could get a bit messy.
Below is a modified return where the result is a negation of the test and the regex is a positive match instead of a negative lookahead. Should work as before but will now also fail the validation check when the email ends with .edu or .org

return !(/\@(me|mac|icloud|gmail|googlemail|hotmail|live|msn|outlook|yahoo|ymail|aol|edu)\./.test(value.toLowerCase()) || /(\.edu|\.org)/.test(value.toLowerCase()));