ericakfranz
12/7/2015 - 10:16 PM

Add a custom redirect url (http://optinmonster.com/) if the subscriber uses a non-business email address such as yahoo, gmail, hotmail, etc.

Add a custom redirect url (http://optinmonster.com/) if the subscriber uses a non-business email address such as yahoo, gmail, hotmail, etc.

jQuery(document).ready(function($){
    $(document).on('OptinMonsterBeforeOptin', function(event, data, object){
      // Grab the email address submitted by the user.
      var email = $('#om-' + data.optin).find('input[type="email"]').val();

      // Test to ensure it is a proper email. Otherwise, redirect to another page.
      if ( /@yahoo.com$/.test(email) || /@gmail.com$/.test(email) || /@hotmail.com$/.test(email) || /@googlemail.com$/.test(email) || /@live.com$/.test(email) || /@aol.com$/.test(email) || /@outlook.com$/.test(email) || /@comcast.net$/.test(email) || /@inbox.com$/.test(email) || /@hushmail.com$/.test(email) || /@lycos.com$/.test(email) || /@zoho.com$/.test(email) || /@gmx.com$/.test(email) ) {
        window[data.optin_js].optin = function(){
          return window.location.href = 'http://optinmonster.com/';
        };
      }
    });
});