Skip to content
/blog

6 min read

How to stop a form losing leads: spam, validation and alerts

A form loses leads to spam, to badly designed validation or to alerts that never arrive. How we build forms, and the test we run before handing over a website.

A contact form loses leads in three ways: spam buries them, badly designed validation turns away people who wanted to write, or the alert never reaches anyone. We prevent this with a honeypot field against bots, validation that only asks for what is needed to reply, tested email alerts, and a real submission before we call a website finished.

What happens to an enquiry after someone presses “Send”?

On most of the websites we build, the form goes to Netlify Forms, the forms service of the hosting platform we publish on. It is our standard for contact forms: no server of our own is needed to receive them, and Netlify stores every submission.

Two filters before it counts as a lead, and a function that alerts the team only when the submission is genuine.

The path has four stops. The browser sends the form. Netlify receives it and runs it through two filters: the honeypot field, which silently discards bot submissions, and a spam filter, which moves suspicious ones to a separate list. Whatever gets through both becomes a verified submission. And this is where our part starts: on each verified submission, Netlify runs a function on the website, and that function emails the team and, if the client wants it, sends a confirmation to the person who wrote.

The internal email is not a raw dump of the fields. It carries the name, the message, the contact details and buttons to reply by email, WhatsApp or phone, and at the end some technical details of the submission, such as the device type. It can also say where the lead came from (the landing page, the site that referred them or the campaign), which is the simplest way to see which channel brings in work.

How do you stop spam without getting in people's way?

With Netlify Forms, the first line of defence is the honeypot field: a hidden field that a person never sees and a bot happily fills in. If it arrives filled in, Netlify rejects the submission without a word; according to its documentation, those submissions do not even appear in the spam list. The second is Netlify's automatic filter, which moves suspicious submissions to a separate list. That list is worth checking now and then: a genuine message can end up there, and it can be moved back to the verified ones by hand.

When the form goes to our own code rather than to Netlify, such as the chat of an AI assistant or the technical audit, we use Cloudflare Turnstile. The browser solves an invisible check and receives a token, and our server validates it with Cloudflare before doing anything else. Cloudflare's documentation is unequivocal: the widget alone protects nothing, server-side validation is mandatory, and each token expires after five minutes and can only be used once.

Form received by Netlify

  • Hidden honeypot field
  • Netlify's spam filter
  • No server of our own
  • The contact form on almost every site

Route with our own code

  • Turnstile in the browser
  • Token validated on the server
  • Request limits
  • The chat and the technical audit
Two kinds of protection, depending on who receives the submission: Netlify or our code.

On a Netlify Forms form, Turnstile has no role: Netlify receives the submission and does not validate it, so the widget would only add weight. And where we do use it, we load it late. In the chat, the widget is mounted the first time someone opens it: mounted with the page, it kept making requests even when nobody was chatting, and in our performance measurements it added load for no benefit.

What should a form validate, and where?

Validation has two jobs: helping the person writing and protecting the person receiving. In the browser it helps, by flagging an empty required field or an email address without an @ before sending. On the server it protects, because what arrives there does not always come from your form. Wherever it runs, the rule is the same: ask only for what you need to reply, and never turn anyone away over a format.

These are the checks we use on the sites we build:

/** Email amb forma vàlida (sense espais, amb @ i domini amb punt). */
export const isEmail = (v: string | undefined): boolean => /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test((v || "").trim());

/** Xifres d'un telèfon (sense espais, guions, parèntesis ni +). */
export const phoneDigits = (v: string | undefined): string => (v || "").replace(/\D/g, "");

/** Telèfon amb prou xifres (9 o més: fix o mòbil espanyol, o internacional). */
export const isPhone = (v: string | undefined, minDigits = 9): boolean => phoneDigits(v).length >= minDigits;
Deliberately permissive validation: the email needs an @ and a domain with a dot; the phone number is counted in digits.

We do not try to guess whether an email address exists: an @ and a domain with a dot are enough. Phone numbers are counted in digits, so “+34 600 00 00 00”, “600-000-000” and “(972) 00 00 00” all pass. Stricter validation would reject real people for typing their number the way they always do, and that lead does not come back.

Why can a form stop working without anyone noticing?

Because when it fails, it almost never fails in front of anyone. It has happened to us: on a new website on Netlify, form detection has to be switched on by hand in the dashboard. Until someone enables it and the site is published again, the form looks fine, but submissions go nowhere and nobody gets an alert. Netlify's documentation confirms it in its own way: detection has to be enabled, and it takes effect from the next deploy.

The second trap is how detection finds forms: Netlify reads the site's HTML when it is published. If the form is drawn by JavaScript, or sits on a page generated by a server, Netlify does not see it. This very website is a case in point: the form is declared in a static HTML file that Netlify reads at publish time, and the contact page sends its data there. Any field not declared in that file is lost.

The third is the alert itself. The function that sends the email needs its keys in the hosting environment, and Netlify's own notifications (email, Slack or webhook) are configured in the dashboard. Without them, leads are stored but nobody is told.

  1. Detection enabled

    In the Netlify dashboard, form detection is switched on for this website.
  2. Fresh publish

    The site is published again so Netlify reads the forms.
  3. Real submission

    We fill in the live form as a customer would, with test details.
  4. The alert arrives

    The email lands in the inbox of whoever needs to read it, not just ours.
The test we run before calling any website with a form finished.

The test is repeated whenever something changes: a new field, a new recipient, a change of hosting. It is part of website maintenance, like renewing the domain.

What to do next

If your site gets few enquiries and you are not sure whether that is down to lack of interest or lost messages, start by sending yourself a message from the live form and see where it lands. If you want a website or a web application where this is already taken care of, our custom websites page explains how we build them. The rest of the technical side (security, performance, domain) is what the technical audit checks.

Got a project in mind?

Tell us what you need: an app, an assistant or a website. We’ll send you a proposal and a fixed quote.