Skip to content

Instantly share code, notes, and snippets.

@brianaohern
Created July 12, 2018 16:25
Show Gist options
  • Select an option

  • Save brianaohern/b21a709c375ef2d50480b5ad8d1b3feb to your computer and use it in GitHub Desktop.

Select an option

Save brianaohern/b21a709c375ef2d50480b5ad8d1b3feb to your computer and use it in GitHub Desktop.
om.Optin.init.submit Example
document.addEventListener('om.Optin.init.submit', function(event) {
// Grab the email address submitted by the user.
const email = event.detail.Optin.data.fields.email;
// 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) ) {
event.detail.Optin.success = function(){
return window.location.href = 'http://optinmonster.com/';
};
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment