How-to · Checked November 22, 2026

How to add a honeypot to an HTML form

Add an extra text input to the form, hide it with CSS, and throw away any submission where it has a value. People never see the field so they leave it empty. Most spam bots fill in every field they find.

It takes one line of HTML and costs your visitors nothing: no puzzle and no delay.

The field

Put this line anywhere inside the form:

<input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off">

The name is what the receiving side checks. FormTango uses _gotcha. If you write your own receiver, any name works, and one that sounds real to a bot, such as website or company, attracts more of them.

Hide it the right way

  • Use type="text" and hide it with CSS. Many bots skip inputs with type="hidden" but fill in text inputs.
  • display:none also hides the field from screen readers, so people using one do not meet a mystery box.
  • tabindex="-1" keeps it out of the keyboard tab order.
  • autocomplete="off" stops browsers and password managers filling it in for real visitors.
  • Do not mark it required.

Check it where the form is received

The honeypot does nothing by itself. The code that receives the form has to look at the field and discard the submission when it is not empty. Do this on the server, not in the page: a bot that posts straight to your endpoint never runs your JavaScript.

With a form backend the check is done for you. In FormTango, a submission with _gotcha filled in is treated as spam, and the field is never stored as data because names starting with an underscore are instructions.

What a honeypot does not stop

Bots that render the page and skip invisible fields, and people paid to send spam by hand, get past a honeypot. Treat it as the first layer. Timing checks, content filtering and rate limits catch more. FormTango runs spam filtering on every form automatically and limits each visitor to 10 submissions a minute per form.

The full set of layers is in how to stop contact form spam, and the term is explained in the glossary.

If real messages are being caught

  • An autofill tool is filling the hidden field. Check that autocomplete="off" and tabindex="-1" are both present.
  • Your own script copies every input into the request and gives the honeypot a value. Send it empty.
  • An automated test fills every field. Leave the honeypot out of the test, or mark test submissions as tests.

Common questions

What is a honeypot field in a form?
It is a text field hidden from people with CSS. Spam bots fill it in, people do not, so any submission with a value in it can be discarded as spam.
Should a honeypot use type="hidden"?
No. Many bots ignore hidden inputs. Use a normal text input and hide it with CSS such as display:none.
Is a honeypot enough to stop form spam?
It stops simple bots, which are most of them. Combine it with rate limits and content filtering, and add a CAPTCHA only if spam still gets through.

Written by the FormTango team. Facts about other services were read from their own pages on November 22, 2026. Spotted something out of date? Tell us and we will fix it.

Keep reading