Try it on your own data
Every report in this article is in the free plan. One snippet for web and apps, up to 10 sites.
Start freeA honeypot field is a form input that people never see or reach and that should arrive empty. Automated spam often fills it, so your server can filter those submissions without asking visitors to solve anything. Make it accessible, add a signed time check, validate on the server and measure false positives.
What you will learn
- Hide the trap with off-screen CSS plus inert, tabindex -1 and a neutral name, so people, screen readers and autofill leave it alone
- Sign the form's timestamp on the server; send very fast submissions to review rather than rejecting them
- In the sample month, rejection stopped 89.0% of spam and wrongly rejected 4 of 562 real senders: measure both
What is a honeypot field?
A honeypot field is an extra form input that people never see or reach, which the server expects to arrive empty. Simple spam software fills every input it finds, so a value in that field marks the submission as automated. Visitors do nothing, solve nothing and usually never know it exists.
The W3C note Inaccessibility of CAPTCHA lists honeypots among the non-interactive alternatives to challenges: easy to implement, even in hand-written markup, and worth considering. The idea is simple. The details decide whether it only catches bots or also catches your customers, so this guide builds one in four parts: markup that people cannot meet by accident, a signed time check, server-side validation with tested outcomes, and measurement of both catches and mistakes.
It is a defensive filter for your own contact, sign-up and comment forms. It will not stop someone who writes a script for your form in particular.
Add the HTML so people never meet it
<form method="post" action="/contact">
<div class="hp" inert aria-hidden="true">
<label for="referral_note">Leave this field empty</label>
<input type="text" id="referral_note" name="referral_note"
tabindex="-1" autocomplete="off">
</div>
<input type="hidden" name="form_token" value="{{ token }}">
<label for="email">Email</label>
<input type="email" id="email" name="email" autocomplete="email" required>
<label for="message">Message</label>
<textarea id="message" name="message" required></textarea>
<button type="submit">Send</button>
</form>
<style>
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
</style>
Each attribute closes a specific hole:
| Attribute or choice | Who it protects | What goes wrong without it |
|---|---|---|
| Off-screen CSS | Sighted users | They see a puzzling extra box |
inert on the wrapper | Keyboard and screen reader users | The field can be focused or announced |
aria-hidden="true" and tabindex="-1" | Users of older browsers | Same, where inert is not supported |
| Visible label "Leave this field empty" | Anyone who gets the page without CSS | They cannot tell what the box is for |
A neutral name such as referral_note | People using autofill | A name like url, email or phone invites the browser to fill it |
autocomplete="off" | People using autofill | More risk of stored values; it is a request, not a guarantee |
The HTML Standard says inert nodes generally cannot be focused and are not exposed to assistive technologies, and that authors should only mark content inert when it is also visually obscured, which is the case here. Inert is not the same as disabled: the standard's rules for building form data skip disabled fields, not inert ones, so the empty honeypot is still sent.
Do not put aria-hidden on something that can take focus. W3C's Using ARIA warns that doing so leaves some users focused on "nothing". Here inert removes focus from the wrapper's contents first.
There is a trade-off in the name. A tempting name such as website attracts more naive bots and also more autofill. Start neutral, measure, and change only if the catch rate is poor.
| Layer | Catches | Risk to real people |
|---|---|---|
| Honeypot field | Software that fills every input | Autofill filling the trap |
| Missing or altered field and token | Posts that never loaded your form | Custom front ends that omit the field |
| Minimum time | Instant submissions | Fast typists and password managers |
| Maximum age | Old reused tokens | Tabs left open a long time |
| Rate limit | Repeated submissions | Many people behind one address |
Reject only on strong evidence; hold or ask to resend when real people could be affected.
Add a signed time check
A person needs a few seconds to read a form and type. A script can post it in milliseconds. To use that, the server has to know when it served the form, and it cannot trust a plain timestamp in a hidden field, since the sender can edit it.
So sign it. When rendering the page, create a token made of the current time plus an HMAC of that time with a secret only your server knows. On submit, recompute the HMAC; if it matches, the time is the one you issued.
Two limits need care:
- Minimum time. 3 seconds is a sample value. Password managers and returning visitors can be quick, so send fast submissions to review instead of rejecting them.
- Maximum age. An expiry stops one token being reused indefinitely, but it is also a time limit on the person. WCAG 2.2 success criterion 2.2.1 (level A) lists a limit longer than 20 hours as one of its exceptions, so a 24-hour expiry stays clear of it. If a token does expire, show the form again with everything the person typed.
If your pages are cached, every visitor gets the same old token. Fetch the token with a small uncached request, or exclude the form page from the cache.
Validate the honeypot on the server
Front-end checks are useless here: a bot can post straight to your endpoint without running any of your JavaScript. All decisions happen on the server. A sample in Node.js, using only the standard library:
const crypto = require('node:crypto');
const SECRET = process.env.FORM_SECRET;
const MIN_MS = 3000;
const MAX_MS = 24 * 60 * 60 * 1000;
const sign = (v) => crypto.createHmac('sha256', SECRET).update(v).digest('base64url');
function issueToken(now = Date.now()) {
return `${now}.${sign(String(now))}`;
}
function checkSubmission(body, now = Date.now()) {
if (body.referral_note !== '') return { verdict: 'reject', reason: 'honeypot' };
const [ts = '', mac = ''] = String(body.form_token ?? '').split('.');
const good = Buffer.from(sign(ts));
const got = Buffer.from(mac);
if (!ts || got.length !== good.length || !crypto.timingSafeEqual(got, good)) {
return { verdict: 'reject', reason: 'bad_token' };
}
const age = now - Number(ts);
if (age > MAX_MS) return { verdict: 'resubmit', reason: 'expired' };
if (age < MIN_MS) return { verdict: 'review', reason: 'too_fast' };
return { verdict: 'accept', reason: 'ok' };
}
The honeypot test is !== '' on purpose: a browser submitting your form sends the field with an empty value, so both a filled field and a missing field are wrong. If your front end builds the request itself with JavaScript, include the empty field in it.
Results of running that function against test inputs:
| Test input | Verdict | Reason |
|---|---|---|
| Empty trap, valid token, 40 s after issue | accept | ok |
| Trap filled | reject | honeypot |
| Trap field missing | reject | honeypot |
| Empty trap, 1 s after issue | review | too_fast |
| No token | reject | bad_token |
| Timestamp edited, old signature | reject | bad_token |
| Tab left open for 25 hours | resubmit | expired |
Keep your normal validation as well: required fields, lengths, allowed characters, CSRF protection. A honeypot replaces none of them.
What to do with a caught submission
| Verdict | What the sender sees | What you store |
|---|---|---|
| accept | The normal confirmation | The message |
| review | The normal confirmation | The message in a held queue, with the reason |
| resubmit | The form again, filled in, asking to send once more | A count |
| reject | A neutral "could not send" with another way to reach you | Reason, time and a short sample, for a limited period |
Do not tell the sender which check failed; that is free tuning advice for whoever is probing. Do not silently discard either, at least not at first: a real person caught by autofill should have another route, and you need samples to find your false positives. Decide how long to keep rejected content, since it may contain personal data.
How to test a honeypot field
- Keyboard only. Tab through the form. Focus must never land on the hidden field.
- Screen reader. Read the whole form. "Leave this field empty" should not be announced.
- Autofill. In each browser and password manager your users have, let it fill the form, then confirm the trap is still empty.
- No CSS. Load the page with styles disabled. The label should explain the box.
- Narrow screens and right-to-left layouts. The off-screen technique must not create a horizontal scroll bar.
- Cached page. Load it the way a visitor would after caching and check the token is fresh.
- Server cases. Submit the test inputs in the table to a staging copy of your own form and compare verdicts.
- After every form change. Redesigns and form builders love to restyle hidden inputs.
Measure what it catches and what it costs
Log one reason per submission and, for the first weeks, label a sample by hand. Sample data for one month of a contact form, fully reviewed:
| Verdict and reason | Submissions | Spam | Real people |
|---|---|---|---|
| reject: honeypot | 1,500 | 1,497 | 3 |
| reject: bad token | 140 | 139 | 1 |
| review: too fast | 120 | 108 | 12 |
| resubmit: expired | 10 | 4 | 6 |
| accept | 630 | 90 | 540 |
| Total | 2,400 | 1,838 | 562 |
What it says:
- Automatic rejection stopped (1,497 + 139) ÷ 1,838 = 89.0% of spam.
- Counting held messages, 94.9% never went straight to the inbox as accepted mail.
- 90 spam messages still got through, 4.9% of spam and 14.3% of what was accepted.
- 4 real people were rejected, 0.7% of real senders. Three of them tripped the honeypot: check autofill first.
- Another 18 real people were delayed (12 held, 6 asked to resend). A too-fast threshold that is one tenth real people argues for review, not rejection.
If spam keeps arriving with empty traps and plausible timing, the sender has adapted. That is the signal to add other layers.
2,400 submissions in one month by verdict
submissionsLimits of a honeypot field
- Targeted scripts read your markup and leave the field alone.
- Automated real browsers may respect CSS and
inertand never fill it. - People paid or inclined to spam pass every automation check.
- Replayed tokens are valid until expiry. Limit submissions per token and per source.
- Account security is out of scope. Login attacks need rate limiting, multi-factor authentication and monitoring; see brute force attack.
For sign-up forms, add email confirmation and the other checks in fake account prevention. If your problem is broader than forms, compare categories of tooling and their false positives in bot prevention solutions.
Reporting on honeypot results in TapCub
TapCub does not add the honeypot or block submissions; your server does. It can put the verdicts next to your traffic, so the sample table above becomes a chart you can watch.
- Send an event per verdict from your server, for example
contact_checkedwithverdictandreasonproperties. Do not include the message, email address or trap contents. - Count browser submits too. With Form submits turned on under Web analytics › Configuration › SDK code and
data-forms="true"on the script tag, TapCub records__formwith the form's id, name and action, not field values; see track form submissions. Scripts that post directly to your endpoint never run the page, so a server count far above__formis itself a clue. - Break down by reason in All-platform analytics › Behavior › Event analysis. A sudden rise in
revieworrejectright after a redesign suggests autofill or caching broke. - Alert on change. Save the rejected share as a formula metric under All-platform analytics › Behavior › Metrics & SQL and monitor it in All-platform analytics › Operations › Monitors (Pro plan or above).
- Mark form releases in Configuration › Annotations.
How to find where real people give up on a form, without recording what they type, is covered in form analytics.
FAQ
Do honeypot fields still work?
They still catch software that fills every input or posts without loading the page, which is a large part of ordinary form spam on many sites. They do not catch scripts written for your form. Measure your own catch rate and false positives instead of assuming either result.
Should the honeypot use type="hidden" or CSS?
Use a normal text input hidden with CSS. A hidden input is an obvious non-user field that simple bots may leave alone. Add inert, aria-hidden and tabindex="-1" so keyboard and screen reader users do not encounter it.
Can browser autofill trigger a honeypot?
Yes, and it is the main source of false positives to watch. Avoid names and labels that look like standard personal fields, set autocomplete="off" while knowing browsers may not always follow it, and test with the password managers your users use.
Is a honeypot enough without a CAPTCHA?
For low-value forms it often is, together with a time check, content filtering and rate limits. For logins, payments or anything worth targeting, use stronger controls. Keep a challenge available for requests that look risky.
Does a honeypot collect personal data?
The mechanism itself needs none. Your logs of rejected submissions may contain names, addresses and messages, so limit what you keep and for how long, and cover it in your privacy notice as required. This is general information, not legal advice.
Sources
- W3C Group Draft Note: Inaccessibility of CAPTCHA, section 2.2.4 Honeypots
- HTML Standard (WHATWG): inert subtrees and the inert attribute
- HTML Standard (WHATWG): form submission and constructing the entry list
- W3C: Using ARIA, fourth rule of ARIA use
- Web Content Accessibility Guidelines (WCAG) 2.2, success criterion 2.2.1 Timing Adjustable
Was this article helpful?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Data Engineer
Writes about event design, data quality, and collection workflows, with verifiable implementation methods for reliable analytics.



