Re: Restricting personal emails from all forms/landing pages

Michele_Stodda1
Level 2

Restricting personal emails from all forms/landing pages

Hi All,

I see that this question has been asked a lot - can you block or restrict personal emails/ISPs from filling out forms?  In my investigations the answer is yes...great, but can I do this on the template level of the form or landing page so I don't have to place code on each and every landing page?

TIA!

11 REPLIES 11
Josh_Hill13
Level 10 - Champion Alumni

Re: Restricting personal emails from all forms/landing pages

either is fine.

Michele_Stodda1
Level 2

Re: Restricting personal emails from all forms/landing pages

Thanks Josh.

How would I do this?  This article (http://developers.marketo.com/blog/restrict-free-email-domains-on-form-fill-out/) doesn't seem to explain how to add to the design studio landing page templates.

thanks:)

SanfordWhiteman
Level 10 - Community Moderator

Re: Restricting personal emails from all forms/landing pages

Like Josh said, in the template works fine.

I recommend packaging all forms behaviors into external JS files, so then they can be shared across templates as well as across LPs.

Michele_Stodda1
Level 2

Re: Restricting personal emails from all forms/landing pages

Thanks Sanford.  Is there any documentation on how to do this? I'm fairly new to JS.

SanfordWhiteman
Level 10 - Community Moderator

Re: Restricting personal emails from all forms/landing pages

Add a <script> tag referencing the external file:

<script type="text/javascript" src="https://somewhere.example.com/path/to/js/file.js"></script>

Since behaviors always reference MktoForms2, the behaviors script needs to run after /forms2.min.js, which creates the MktoForms2 object. Since Marketo-hosted LPs automatically insert /forms2.min.js in the HTML for you, the easiest way to make sure of the right order is to put your behavior <script> right before the closing </body> tag. (There are other ways to manage the dependencies but I imagine this will be easiest for you.)

Hoi_Nguyen3
Level 2

Re: Restricting personal emails from all forms/landing pages

If anyone is having issue using the javascript that this article (https://nation.marketo.com/external-link.jspa?url=http%3A%2F%2Fdevelopers.marketo.com%2Fblog%2Frestr... ) provides, try swapping out the onValidate function with the onSubmit function.

My colleague and I discovered that the onValidate function can often times be buggy.

Good luck everyone!

Hoi

SanfordWhiteman
Level 10 - Community Moderator

Re: Restricting personal emails from all forms/landing pages

I strongly disagree with this blanket recommendation. These are different steps in the form flow and moving callbacks around like this can be disastrous.

Please explain in detail the behavior you believe to be buggy and how to reproduce it. I've been developing with the Forms API for years, including with a commercial product, and onValidate has always worked predictably.

Hoi_Nguyen3
Level 2

Re: Restricting personal emails from all forms/landing pages

It wasn't a blanket recommendation but something to try if you find your javascript not working.

We placed the script at the bottom. The javascript executed every other function properly. It was only when we swapped out onValidate with onSubmit that we got back the expected result.

Again, definitely consider other ramifications of swapping the two functions. But for us, we got what we needed by swapping onValidate with onSubmit.

SanfordWhiteman
Level 10 - Community Moderator

Re: Restricting personal emails from all forms/landing pages

Show me your page with that code.