Prevent free emails

Hey man can you give me some light about how to use the javascript to prevent the use of free email address in a form in Mautic

Related to this post

https://www.mautic.org/community/index.php/6304-personal-email-corporate-email-validation



Thanks

Thanks i will try

Hey man can you give me some light about how to use the javascript to prevent the use of free email address in a form in Mautic
Related to this post
https://www.mautic.org/community/index.php/6304-personal-email-corporate-email-validation

Thanks

Hey,

As per my previous post, I have found two solutions. The first is the javascript solution, which should work on all browsers, the major drawback is that the email validation message in this method appears as a browser alert, which is not very attractive (this may or may not be important to you).

The second method uses regular expression pattern matching, which uses the HTML5 pattern attribute for the form’s email input element. Support for this method does not work on old browsers, but it is more attractive from a UI/UX point f view.

Both methods depend on manually copying your form from Mautic in to your landing page. You could try the javascript method with an automatic form, but I’m not sure this would work.

So, assuming you have a landing page, and assuming you have manually copied the Mautic form in that landing page (Including CSS styles, mautic script, and form HTML). Then you would simply need to copy the following javascript code in to the landing page before the closing tag.



As each form is unique, there are a few variables that you would need to change in order for this to work for you:

  1. The first is “YourFormSubmitButtonID” if you inspect the submit button element, you will see it has an ID attribute. Copy and paste this after the hashtag in the code above.

  2. The second is “YourFormEmailInputID” if you inspect the form’s email element, you will see it has an ID attribute. Copy and paste this after the hashtag in the code above.

  3. You can also change the alert message to your liking.

  4. You can also filter additional email providers, simply by adding the domains after the last one highlighted in bold above like so (?!freeemaildomain.com)

Once you have modified the code, simply copy/paste it and it should work