Can I Use IP Filtering to Block Spam?

Follow

If you’re getting a lot of spam messages from your landing page you may be tempted to use IP filtering to block the spam. Unbounce strongly recommends NOT to use IP filtering to block incoming spam.

ISPs may reuse the same IP address for numerous customers, so any filtered IP addresses may inadvertently prevent future legitimate customers from accessing your landing page, not just the spammers that you were trying to block.

If you're driving traffic to your page through an Ad or email campaign, or sharing the link directly with your visitors, we recommend hiding your pages from search engines. Hiding your pages from organic search engines lessens the chances of bot/spam traffic locating your landing page.

If you’d like to find some legitimate ways of blocking spam messages, check out the following below:

  • Adding Custom Validations to Form Fields:

If you want to add more specific form validation rules, you can do that using custom JavaScript!


This is not an official Unbounce feature. This functionality is based entirely on third party code, and has only been tested in limited applications. Since this isn’t a supported Unbounce feature, our support team will be unable to assist if things go awry. So if you are not comfortable with HTML, Javascript and CSS, please consider consulting an experienced developer.

Part 1: Define a validation rule
Copy the following script and paste it into the Javascripts section of the builder:

<script>
window.ub.form.customValidators.myCustomRule = {
isValid: function(value) {
return value === 'I accept';
},
message: 'Your entry is invalid',
};
</script>
Replace myCustomRule with a unique ID (name) for the rule. You’ll need this later.

Replace isValid with a function that takes the value as an argument and returns true if the value passes validation, or false if not. (The above example requires the user to enter ‘I accept’ exactly.)

Replace message with the error message that you would like to show when the user’s input does not match (optional)

Part 2: Apply the rule to form field(s)
Copy the following script and paste it into the Javascripts section of the builder:

 

<script>
window.ub.form.validationRules.my_form_field.myCustomRule = true;
</script>
Replace my_form_field with the ID of the form field you want to apply the rule to

Replace myCustomRule with the rule ID you set when defining the rule above

This part of the script can be repeated if you would like to apply the same validation rule to multiple form fields.

Examples
Here are some examples of validations that this can be used to create:

Canadian postal codes
<script>
window.ub.form.customValidators.canadianPostalCode = {
isValid: function(value) {
return /^([a-zA-Z]\d[a-zA-z]\s?\d[a-zA-Z]\d)$/.test(value);
},
message: 'Please enter a valid Canadian postal code',
};
</script>
US ZIP codes
<script>
window.ub.form.customValidators.usZipCode = {
isValid: function(value) {
return /^\d{5}([\-]?\d{4})?$/.test(value);
},
message: 'Please enter a valid US ZIP code',
};
</script>
Non-webmail email addresses

<script>
window.ub.form.customValidators.nonWebmailEmail = {
isValid: function(value) {
return /\@(?!(me|mac|icloud|gmail|googlemail|hotmail|live|msn|outlook|yahoo|ymail|aol)\.)/.test(value.toLowerCase());
},
message: 'Please enter your work email address',
};
</script>