Solved

Email Validation Script Working on per-page basis but not when applied domain-wide

  • 12 January 2024
  • 6 replies
  • 84 views

Badge

Hi there, following this community post from former unbounce staff I was able to add JS snippet to select landing pages to prevent form submissions with spam domains 


I’ve confirmed it works when applied on a per-page basis but when I put it in script manager to make it domain wide, it doesn’t work anymore unless the script is on that page already.

here's what it looks like on a page
 

<script>
window.ub.form.customValidators.EmailDomainValidation = {
isValid: function(value) {
return /\@(?!(me|mac|qq|yandex|gamil|aol|tasla|msn|teleworm|business|getmail|mailinator|mailina|mail|hhh|domain|gmailr|bussiness|businessmail|jourrapide|armyspy|hldrive|gmailinator|eamail|tech|email|info|armyspy|manimailinator|mailin|memail|hhh|gamail|fuck|memail|email|asdfasd|out|efu|ko|domain)\.)/.test(value.toLowerCase());
},

message: 'Please enter a valid email address',
};
</script>
<script>
window.ub.form.validationRules.work_email.EmailDomainValidation = true;
</script>

I’ve tried placing it in the <head> in script manager, but that didn’t work. Any advice is appreciated as I’m not a technical person. 

 

At the end of the day we are validating domains with hubspot so even if a user submits a spam email in unbounce they won’t be synced into our contacts but I’d still like to keep our stats as clean as possible in unbounce.

 

Thanks!

icon

Best answer by Hristian 17 January 2024, 08:06

View original

6 replies

Userlevel 7
Badge +3

Hi @REMIM

There might be a few different reasons why this doesn’t work when applied through the script manager. 

Can you share an example page where you have the script through the script manager but not on the actual page. This way we can try to help you figure it out.  

Badge

Hi @Hristian 

 

Here I created a content nuked testing page, I’ve confirmed it works with the script enabled on-page but again, not through script manager 

 

https://start.activestate.com/test-email-valid/

Userlevel 7
Badge +3

Hey @REMIM

I don’t see the custom validation script anywhere on the page you’ve shared. 

Do you have the script running on it through the script manager? 

Badge

Hi @Hristian it should be enabled, just in case though I deleted the old one and recreated it. It is set to enabled. Would you mind checking one last time? 

 

Userlevel 7
Badge +3

Hi @REMIM

It seems to be working for me now. (screen shot attached). 

When I try an aol.com email it fails the validation and keeps on insisting I input “a valid email address” as per the message in the script. 
 



If I change/add a letter to the domain like (aoli.com) it passes validation. 

 

 

Badge

Hi @Hristian  figured it out, silly mistake.

When the script is placed on-page it works in preview mode, however when it is placed domain wide it won’t work in preview mode but will work if just going to the URL directly. 

I had only done my testing in preview mode for both instances.

 

Thanks for helping me out! 

Reply