Prevent Consumer Email Address Submissions for B2B

We are looking to prevent consumer email domains (gmail.com, yahoo.com, etc.) in form submissions, given that it makes follow up outbound much harder when respondents also put in false company names and phone numbers. We use Hubspot, which has this setting on their form fields, but it doesn’t apply on an Unbounce form submission that we then sync over to Hubspot.

Hi @mharr066,

You’ll need to compile a list of what domains you don’t want to allow and write up a custom JS script that would check against the list.

If it’s on the list, it would prevent the form from submitting.

Best,
Hristian

Hi @mharr066
Welcome to Unbounce Community!

Try this snippet:

var rejectList = [ "gmail.com" , "yahoo.com" ];

function validateEmailField()
{
var emailValue = $('#email-input').val(); // To Get Value (we can also use getElementById)
var splitArray = emailValue.split('@'); // To Get Array

if(rejectList.indexOf(splitArray[1]) >= 0)
{
// Means it has the rejected domains
document.getElementById("submit-id").disabled = true; // To disable the button
}
document.getElementById("submit-id").disabled = false; // To enable the button

}

Replace email-input with the real ID of your form input field and submit-id with the real ID of your submit button. Let me know how it goes :slight_smile:

Hi @6cmarketing, thanks for the code snippet! I apologize for the novice question, but where would I find the values for the form input field and the submit button you mention? I’ve looked for email-input and submit-id in the source code but I can’t seem to find them.

Thanks so much your your help!
Matt