Welcome to the Instapage Support Center

|

Business Email Validation

If you have a lead capture form that asks for the visitor's email address and you want to only receive business emails, you can implement the snippet below on your page.

Add the code below in the Javascript - Footer section of the page editor:

<script>
var label = 'E-mail';
if (window.__page_generator) {
window.__custom_form_validations = [
{
fieldName: label,
validationFn: function (input) {
var standardEmail = /^.+@(gmail|google|yahoo|outlook|hotmail|msn)\..+$/ig;
var businessEmail = /^.+@.+\..+$/g;
return {
isValid: !standardEmail.test(input.value) && businessEmail.test(input.value),
message: window._Translate.get('field: Please enter your business email address.'),
};
},
},
];
} else {
$.validator.addMethod('validateEmail', function(value, element) {
var standardEmail = /^.+@(gmail|google|yahoo|outlook|hotmail|msn)\..+$/ig;
var businessEmail = /^.+@.+\..+$/g;
if (value.match(standardEmail)) {
return false;
} else if (value.match(businessEmail)) {
return true;
}
});
$('form [name="' + base64_encode(label) + '"]').addClass('validateEmail');
$.extend($.validator.messages, {
validateEmail: 'field: Please enter your business email address.'
});
}
</script>

You will need to edit the bolded and italicized sections from above to contain the exact name of your field and the desired error message that will be shown to visitors who enter a non-business email address. Make sure that you leave the single quotes at the beginning and end of the text that you replace.

If your field is named exactly E-mail you can leave the code unaltered, but if it is named "Email", "Email address", "E-mail address", or if it is in a different language (e.g. "Correo electronico"), you will need to add the exact name of your field in the code, on the second row, in order for it to work.

Have more questions? Submit a request
Was this article helpful?
1 out of 1 found this helpful

Need Further Help?

Tell us what you need and we will be happy to assist you.

Our team of expert support staff and our community can answer your questions. Submit a ticket, or reach out on live chat!