Block email suffixes from completing forms? | Community
Skip to main content
Mark_Farnell
Level 5
July 4, 2013
Question

Block email suffixes from completing forms?

  • July 4, 2013
  • 13 replies
  • 4644 views
Is it possible to block certain email suffixes from completing forms (with a message to advise why) e.g. @gmail.com, @outlook.com, @competitor-domain.com?

Would it involve some form of custom script/html/code?

I assume we could not send information to these email addresses by adding them to a black list or marketing suspend them and use that in the flow of the campaign, but this doesn't look so good i.e. looks like we can't deliver the reply rather than choosing not to.  So would prefer to block these types of email addresses on entry with a validation message.
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

13 replies

February 26, 2014
I checked and the forms 1.0 on our site (conductor.com) are still validating the email address and displaying an error message if the email domain is a public domain.
February 28, 2014
I've narrowed down my issue on "1.0" forms - we keep this code in a Snippet so that if we want to add a competitor domain to the list, or a new free/junk mail domain starts popping up, we only need to edit in one place and reapprove the pages VS manually updating 400+ pages with forms. 

Welp...for some reason, perhaps an update, Marketo is now automatically adding a "CDATA" tag to my code into the Snippet. I've tried manually deleting, pasting new code w/o CDATA, and createing a new Snippet - but the CDATA tag keeps appearing...and I learned, CDATA causing anything in the tag to be ignored. 

:(

I've reached out to support and am hoping they can either override whatever is causing the tag to be added (or perhaps figure out why it's editing user added code to begin with). Fingers crossed...I reallllllllllllllllllly don't want to go back to the "old way" and have to update every form page whenever something like sharklasers.com starts appearing on our forms (ps, that's a real junk email domain)!

Anyone here got any inside scoop on if/when we can add our own javascript to form 2.0 pages? They sure look nice, but I'll choose function over fashion every time.
haliddelkic
Level 3
March 3, 2014
Someone has kindly posted a new JavaScript code (copied below) that works with Editor 2.0 on blocking certain domains.

Although it does work, there is a chance it will play havoc with your Submit button. I was using one of the custom designs and functionality was affected. We don't have JS developers/knowledge so have removed the custom HTML. 

Here is the discussion with new code for anyone interested: https://community.marketo.com/MarketoDiscussionDetail?id=90650000000PlhSAAS

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
var $jQ = jQuery.noConflict();
 
var invalidDomains = 
[
"hotmail.com",
"yahoo.com",
"aol.com",
"gmail.com",
];
 
 
$jQ(document).ready(function(){
if ($jQ('.mktoButtonRow').length == 0) {
window.setTimeout(function(){
emailValidation();
}, 500);
} else {
emailValidation();
}
});
 
$jQ('#Email').bind('blur', function(){
if (isEmailValid()){
var $error = $jQ(this).parent().find('.mktoError');
if ($error.length > 0) {
$error.fadeOut(200, function(){
$error.remove();
$jQ('#Email').removeClass('mktoInvalid');
});
}
}
});
 
 
function emailValidation() {
var $buttonRow = $jQ('.mktoButtonRow');
var submitText = $buttonRow.find('button').html();
var $replacement = $jQ('<input id="replacementButton" type="button" class="mktoButton" value="' + submitText + '" />');
$buttonRow.hide();
var buttonRowContents = $buttonRow.html();
$span = $jQ(buttonRowContents).html('');
var $replacementRow = $jQ('<div class="mktoFormRow" />').append($span.append($replacement));
$jQ('.mktoFormRow :last').after($replacementRow);
$jQ('#replacementButton').click(function(){
console.log('debug1');
if (!isEmailValid()) {
console.log('debug2');
var $error = $jQ('#Email').parent().find('.mktoError');
if ($error.length == 0) {
$error = getError('Please provide a business or institutional email address');
$jQ('#Email').after($error);
}
$error.fadeIn(200);
$jQ('#Email').removeClass('mktoInvalid').addClass('mktoInvalid');
return;
} else {
console.log('debug3');
$jQ('.mktoButtonRow button').trigger('click');
}
});
}
 
function isEmailValid() {
var email = $jQ('#Email').val().toLowerCase();
for(i=0; i < invalidDomains.length; i++) {
var invalidDomain = invalidDomains[i].toLowerCase();
if (email.indexOf(invalidDomain) !== -1) {
return false;
}
    }
return true;
}
 
function getError(message, detail) {
var $container = $jQ('<div class="mktoError" style="right: 0px; bottom: -47px; display: none" />');
var $arrow = $jQ('<div class="mktoErrorArrowWrap"><div class="mktoErrorArrow"></div></div>');
var $errorMessage = $jQ('<div class="mktoErrorMsg" />').html(message);
if (typeof detail == 'string' && $jQ.trim(detail) != '') {
$errorMessage = $errorMessage.append($jQ('<span class="mktoErrorDetail" />').html(detail))
}
return $container.append($arrow).append($errorMessage);
}
</script>