Re: Preventing personal email address being filled out on form

Tom_Liolios4
Level 4

Hi all,

On several landing pages, I would like to prevent personal email addresses (yahoo, gmail, hotmail etc.) from being filled out on the form.

Initially, I thought I could edit some rules in the form, but this seems to be impossible. I do not want to edit my template, as it would effect all my landing pages.

Does anyone know how to ensure that only on a few landing pages, I "forbid" email addresses containing a certain domain name from being entered?

I found another discussion in the Marketo community referring to a certain HTML script, which should work. Unfortunately, I cannot get it to function properly.

Appreciate all the help!

Thanks,

Tom

16 REPLIES 16
Chris_Vanderma1
Level 4

If anyone can't get this script working like I haven't been able to for the last hour, here is a tip. Make sure the script is after the form in the HTML of the page. That solved it for me.

Robb_Barrett
Level 10

Here's an idea - feel free to shoot it down, but...

You would have to make a change to your template. Where you have your other scripts, put in {{my.Custom-Script}}.

Now, copy the above mentioned code, open up notepad, paste it and save it as restrict-public-email.js. Upload it into design studio and grab the URL.

In the programs you want it, past <script src="<insert URL here>"> into your Custom-Script text token.

Robb Barrett
Tom_Liolios4
Level 4

Thanks Robb. I'll definitely try that one out.

Justin_Cooperm2
Level 10
Tom_Liolios4
Level 4

Yes I did! This is the HTML script I tried, but it does not work. Furthermore, the article is about 2 years old, so perhaps outdated?

I'm hoping for new information that could help me.

Thanks,

Tom

Justin_Cooperm2
Level 10

That should still work...is this an embedded form on an external webpage? Or are you using a Marketo landing page?

Tom_Liolios4
Level 4

Hi Justin,

Should it also work on a Marketo landing page? And if so, would you know where to implement it?

Thanks!

SanfordWhiteman
Level 10 - Community Moderator

A MktoForms2.whenReady listener works on Marketo or non-Marketo pages.

Please link to your URL so we can troubleshoot actual code.

Danielle_Wong
Level 8 - Community Advisor

Is there a way to get the code http://developers.marketo.com/blog/restrict-free-email-domains-on-form-fill-out/  to work for Alternate Email Address field on my form too?

Thanks

SanfordWhiteman
Level 10 - Community Moderator

Danielle Chan without in any way retracting my critique of that old code, here's how you'd use it for multiple email fields: MktoForms2 :: Multiple Email fields w/questionable validation

Again, though, not really the complete/correct way to match freemail domains.

Danielle_Wong
Level 8 - Community Advisor

Hi Sanford, do you know how to edit the code so that the error alert message appears just above the submit button in addition to near the field? I have a long form, and I'd like the message to appear when they click the submit button so they don't have to scroll up and down looking for why the form isn't submitting. Thank you!

SanfordWhiteman
Level 10 - Community Moderator

The native error message can only be in one place at a time.

But check the CodePen now. I added the option showMessageNearSubmit. If you set this to true (defaults to false) then the message also appears next to the Submit button. You can style the message using CSS.

Danielle_Wong
Level 8 - Community Advisor

Thanks Sanford. I was able to try it out on the codepen link. The code we decided to use is a bit different from yours, so I don't think I can implement your code. For example, here is a sample page with the code we are using. IEEE 

Danielle_Wong
Level 8 - Community Advisor

Thanks so much Sanford!

SanfordWhiteman
Level 10 - Community Moderator

Yes, but you shouldn't be using that code anyway as it's broken (it will say danielle@outlook.chanco.com and chris@live.vandermerel.net are free emails, when that's obviously not true).

You can find better code by searching the Community, and I can help you adapt it to check multiple email-type fields.

Tom_Liolios4
Level 4

I am using a Marketo landing page.