Menu

1 / 2

How to stop contact form spam

DEV Community: html·Harsimran jeet Singh·4 days ago
#zbHJ5Ww3
#devto2#devto#dev#form#spam
Reading 0:00
15s threshold

Contact form spam comes from three places:

Bots that fill in every field they find on the page.

Scripts that POST straight to your form's URL , never loading the page at all.

People and AI tools writing real-looking messages : SEO offers, "I noticed your website…" pitches, crypto and loan offers.

Each defense below stops some of these and misses others. The cheap ones go first.

1. Honeypot field

Add a field that people never see. Bots fill it in; people leave it empty. If it has a value, drop the submission.

<div class= "hp" aria-hidden= "true" > <label> Leave this empty <input type= "text" name= "website_url" tabindex= "-1" autocomplete= "off" ></label> </div>

<style> .hp { position : absolute ; left : -10000px ; width : 1px ; height : 1px ; overflow : hidden ; } </style>

Enter fullscreen mode

Exit fullscreen mode

Tips:

Use a believable name like website_url or company_fax .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.