Prevent form submits from generic email domains | Community
Skip to main content
December 15, 2016
Solved

Prevent form submits from generic email domains

  • December 15, 2016
  • 2 replies
  • 7427 views

Would like to block people from using a generic email to submit a form. We're blocking them on the back end by removing them from flows but would like to show an error message or something to try to get people to use their business addresses instead. Any way to do that?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Grégoire_Miche2

Hi Andrew,

This is quite well documented in the community.

Start here: http://developers.marketo.com/blog/restrict-free-email-domains-on-form-fill-out/

-Greg

2 replies

Grégoire_Miche2
New Participant
December 15, 2016

Hi again Andreww,

You can also use a paid (and far more advanced) service such as Etumos Verify - Etumos

-Greg

Grégoire_Miche2
Grégoire_Miche2Accepted solution
New Participant
December 15, 2016

Hi Andrew,

This is quite well documented in the community.

Start here: http://developers.marketo.com/blog/restrict-free-email-domains-on-form-fill-out/

-Greg

January 11, 2017

Hi Greg, what if I need one form on a page to block invalid email addresses but the other not to - we have a download form we want to block and a contact us form we do not want to block. Is that possible?

Also, do you know if the script will work if implemented through Google Tag Manager? Our script doesn't seem to be working.

Thanks!

-Andrew

SanfordWhiteman
New Participant
January 12, 2017

Hi Andrew​,

Better to open a new thread in future (a thread tagged Correct can't have additional correct answers, plus you can't tag it if you're not the owner).

what if I need one form on a page to block invalid email addresses but the other not to - we have a download form we want to block and a contact us form we do not want to block. Is that possible?

Sure, perfectly possible.  By default, most Forms 2.0 custom behaviors attach to all forms on the current page, both because it's easier to write examples that way and because it's usually what you want. But you can easily reserve behaviors for a subset of forms (this also makes it easier to include the same JS on every single page, since it will auto-adjust depending on what form has been embedded).

MktoForms2.whenReady(function(form) {

// we will get here for every form, but...

if( [123,456].indexOf(form.getId() >= 0 ) {

   // ... this code will only run for form IDs 123 and 456

   form.onValidate(function(valid) {

     // extended validation, etc...

   });

});

});

Also, do you know if the script will work if implemented through Google Tag Manager? Our script doesn't seem to be working.Andrew

Injecting scripts asynchronously (which is what you're doing by using GTM) works as long you maintain the load order of dependent scripts.

So forms behaviors JS (making use of MktoForms2.someEvent) loaded via GTM must load after the core forms2.min.js library has completely loaded, because MktoForms2 won't exist until it's created by the library.  If forms2.min.js and your behaviors JS load independently and asynchronously, they can finish in either order, so some % of the time the code is guaranteed to fail.

Although it can be made to work perfectly, managing dependencies can be difficult if you don't have command of all the tech involved. So it may be better for you to eschew GTM here. I was debugging something exactly like this at a client today (hi guys! ).