StuartRead.com

Restrict Lead Forms to Business Email Addresses

Using Elementor and GeneratePress

Restrict Lead Forms to Only Business Email

Note: this post describes the usage for the Elementor Pro pagebuilder and the GeneratePress – GP Pro Theme – but it is easily adaptable for others.

If you are like most B2B companies lead quality is important, and noise in the sales pipeline is detrimental to results. We found a lot of “freemail” or Hotmail, Gmail, Yahoo accounts who submit demo request are either timewasters, fake accounts testing our demo process, startups without a business yet and a random assortment of client who are trying to sign in? (I can’t help them read).

Don’t get me wrong we want the startups business, and are happy to chat to them on the phone with sales support, qualify them and then demo with sales… but not direct to sales!

To quickly increase the lead quality and prevent the standard “freemail” addresses we can implement some Javascript quite easily that prevents them submitting the form if one of the emails addresses you set are present – Cool.

Now this is not going to stop tech savvy persistent spammers, that is another entirely separate post, this is a simple message block on the form. The source code reveals the emails you are blocking, but in a normal situation your leads are not playing games.

It’s also easy to update the list and deploy quickly – and here is how you do it.

My Setup

I use the following, so you will have to adapt to suit your own environment:

    • WordPress
    • GeneratePress – GP Pro and the Theme
    • Elementor Pro (form component)

How to

Navigate to the page with your lead capture form and note the page URL (you will need this later).
Example Elementor lead capture form

On this page inspect and find the form field for the email address field being checked – In our case:

We are going to need the ID: #form-field-email1

Now find the submit button and the ID:

Note: you can change field IDs and button IDs in the Elementor Form section, the fields IDs are preceded with: “form-field-YOURID“, the buttons do not, it is just your ID.

Now we need to grab the Javascript from below put is somewhere so it works on the form.

In WordPress Admin, under >Appearance >Elements > Add New

Choose “Element Type” – Hook

This will allow us to hook in to the the correct part of the Theme Template.

Name it and copy the Javascript code into the body.

Select Hook: wp_footer

In the Javascript you just pasted change this: $(‘#lead-submit‘) and this $(‘#form-field-email1‘) with your form IDs.

<script type="text/javascript">
$(document).ready(function(e){
$('#lead-submit').click(function(){
var email = $('#form-field-email1').val();
var reg = /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)(?!yahoo.co.in)(?!aol.com)(?!abc.com)(?!xyz.com)(?!pqr.com)(?!rediffmail.com)(?!live.com)(?!outlook.com)(?!me.com)(?!msn.com)(?!ymail.com)([\w-]+\.)+[\w-]{2,4})?$/;
 if (reg.test(email)){
return 0;
}
else{
alert('Please enter a business email address - or call us and we can help set you up');
return false;
}
});
});
</script>

 

Now the code element is to be assigned to a particular page, post, CPT   – so it only fires on that page:

In the control section select >Display rules and then select where your form page is (or multiples).

Save and we are good to go…

Test Gmail addresses or any listed in the code above on my form here, or on your site

Blocking more free mail addresses

If you want to block other emails, just add more of these: (?!hotmail.com) marked in red to the code.

You could update your site with this list of “burner emails” if you were getting persistence spam.
Burner Emails:

Alternative Flow/Improvements

I am considering an alternative lead flow that captures the “free mail” address and directs them through different qualifying funnels. If I do this I’ll create a new post for it how its done.

I’d also like a separate list for domain email updates, and a better message popup with links to direct the lead.

Conclusion

A fast way to add some restrictions on your forms – it not perfect but work in most cases.

Other Stuff

Can I build it?

Building Popular Websites Using Low Code So, I thought it would be fun to test my skills and try to build popular

Leave a Comment