Block specific words - email form

Hey everyone,

Is there a way to make sure specific words are added to the message field in the form that they don’t get accepted? Maybe don’t get send to the receiver. I use @Bill , DeSpam, but these spammers still get through.
You know how we all get spammers who add words like “quote”, “website”, s.e.o., “offer”,… It sure would be great to have better control.

Hi!

Did you mean that when I type in the forbidden word, it immediately converts it to the word SPAM, for example?

CleanShot 2024-08-27 at 18.54.49

Wow, that was interesting! I did not know Blocs could do that. Kind of Cool. Boy, would that frustrate the spammers. I could use that. Thanks for your reply.
How did you do that?

At a basic level, the form does not know, a short code solves the problem. 10 minutes and I’ll post it in the forum to see if anyone else can use it.

1 Like

That’s really kind of you. :grinning:

Here is the code, place it in the HEADER section.

Instead of “sample”, you enter what you want, those words will be filtered out.

if you change the texetera id from ‘message’ to something else, don’t forget to rewrite it in the code as well.

Hope it works, try it. :wink:

<script>
document.addEventListener("DOMContentLoaded", function() {
    const forbiddenWords = ["sample", "sample1", "sample2", "sample3"];
    
    const messageBox = document.getElementById('message');
    if (messageBox) {
        messageBox.addEventListener('input', function() {
            let words = this.value.split(/\s+/);
            words = words.map(word => forbiddenWords.includes(word.toLowerCase()) ? 'SPAM' : word);
            this.value = words.join(' ');
        });
    }
});
</script>
1 Like

This is way beyond my knowledge, so I’ll trust you. Your’s worked, why would mine. :grinning:

1 Like

Ok,
If that textarea can be seen by normal users, then it is useless, as a normal user would fill that it and then I assume filtering on your email client would incorrectly mark it as spam. A BOT will fill in hidden elements which triggers a reject, ie. honeypot and that’s what DeSpam has.

Just a note to @KBConcepts : If you are getting email coming from an actual form, then a human must be filling it out, as bots are blocked. But if it’s a regular email (not from the form), then a bot has scraped an exposed email off your site & you will forever get spam, as it’s too late and it’s sold to every spammer in the world.

Bill
BricsDesign

2 Likes

Well said Bill. :slightly_smiling_face:

What I wrote is just a plain word filter. :wink: