A honeypot field for your contact form
A honeypot is one extra input that people never see and bots fill in. A message that arrives with it filled in is spam. It costs your visitor nothing and takes one line of HTML, as long as you hide it the right way.
14 days free, no card. Paste the address where the code says YOUR_FORM_ID.
<!-- inside your <form>, next to the real fields -->
<input type="text" name="_gotcha"
style="display:none"
tabindex="-1"
autocomplete="off">
Why each attribute is there
-
1
type="text", not hidden
An input with type="hidden" tells a bot the field is not for typing, so it can leave it alone. A text input looks like any other field, and a bot that fills in every field fills in this one.
-
2
Hidden by style
style="display:none" keeps it off the screen and out of screen readers, so no person sees it or hears it read out.
-
3
Out of the Tab order
If a stylesheet ever shows the field, tabindex="-1" still keeps the Tab key from landing on it.
-
4
No autofill
autocomplete="off" asks the browser not to fill it in from saved details, so a real visitor does not spring the trap by accident.
Use the name your form backend reads
FormHaven reads _gotcha (Formspree's name), _honeypot (Formspark's) and _honey (FormSubmit's), so a form moved from any of them keeps its trap as it is. The trap field itself is never stored with the answers or shown in your email.
<input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off">
<!-- also read: name="_honeypot" or name="_honey" -->
Test it from the command line
Send one message with the field filled in. You get the same answer as a real message, because a bot must not learn it was caught, and the message shows up in the form's spam list as caught by the hidden trap field. On a form set to keep nothing, it is dropped instead.
curl -X POST https://formhaven.net/f/YOUR_FORM_ID -H "Accept: application/json" \
-d "email=test@example.com" -d "message=hello" -d "_gotcha=x"
# {"ok":true,"message":"Thanks, your message was received.", ...}
What gets past it, and what to pair it with
A honeypot catches bots that fill in every field. A bot written for your form, one that drives a real browser, or a person pasting offers by hand leaves it empty. Pair it with the bot check, which has the browser solve a small puzzle before it sends, and with spam words for what the message says. Turn on the bot check in the form's settings and add this line once to the page.
<script src="https://formhaven.net/bot-check.js" async></script>
Questions about this setup
- Is a honeypot enough on its own?
- It depends on who is posting. It costs nothing, so keep it on every form, and turn on the bot check the day spam starts getting past it.
- Does it hurt accessibility?
- Not when it is hidden with display:none: screen readers skip it and the keyboard cannot reach it. A field moved off screen with CSS instead stays in the reading order, so a screen reader user could end up filling it in.
- Should I check the field in my own JavaScript?
- No need. FormHaven checks it when the message arrives. A bot that posts to the address directly never loads your page, so it never runs a check that lives there.
- What does a visitor see if they fill it in by accident?
- The normal thank-you page. The message is filed as spam and not emailed, so look in the spam list if someone says you never answered.
More to read
Get your form address in a minute
14 days free, no card. Then €1 per form a month, €0.50 from the 11th form.