preventing non-company addresses from completing forms

Anonymous
Not applicable

preventing non-company addresses from completing forms

Before form 2.0 was released there was a work around for preventing individuals from using their personal email address when completing forms. How do we prevent individuals from using aol.com, gmail.com, or yahoo.com from being entered into the email address field?
Tags (1)
3 REPLIES 3
Edward_Masson
Level 10

Re: preventing non-company addresses from completing forms

Some simple Jquery on the landing page set up to look for the @gmail.com, @aol.com @hotmail.com etc. can do the trick.
Anonymous
Not applicable

Re: preventing non-company addresses from completing forms

Could you provide the jquery to put on the landing page? 
Alok_Ramsisaria
Level 10

Re: preventing non-company addresses from completing forms

Hi Danielle,


Try replacing your old validation code with the following;


<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>


Hope this helps!