Why isn't the browser's own validation enough?
You add required and type="email" to your inputs and assume the form is checked. Then a message arrives from someone called “ ” with the address emma@example, and you have no way to reply. The browser did exactly what the HTML standard asks of it, which is less than you need.
We asked Chromium what it thinks of four inputs that should all be refused:
| Input | Browser |
|---|---|
A name of three spaces in a required field | Accepted |
emma@example in a type="email" field | Accepted |
emma@ in a type="email" field | Refused |
“Hi” put into a minlength="10" textarea by a script | Accepted |
Three of the four pass. required is happy with spaces, an address without a dot after the @ is valid by the standard's own rule, and minlength only counts what a person typed, not what a script or a password manager filled in. So the form needs a few lines of its own.
What does a validated React form look like?
This is the component we ran, with only the test switches taken out. It needs only useState and sends with fetch to any endpoint that answers JSON. Each choice in it is there because a test needed it.
The noValidate attribute turns off the browser's own bubbles so your messages are the only ones the visitor sees. Each rule trims the value first, which is what catches the name made of spaces. A field shows its message only after the visitor has left it, because nobody wants to be told the email is wrong while they are still typing it.
Each message also gets a fixed slot under its field. Our first version added and removed those paragraphs, and when a message vanished on blur the Send button jumped up under the pointer. In that run 4 of the 8 cases that click Send lost the click to the page, and the form never saw it. Reserving the space fixed it. The aria-invalid and aria-describedby attributes let a screen reader announce the message, and focus moves to the first broken field so a keyboard user does not have to hunt for it. Our guide to an accessible contact form goes further on that side.
import { useRef, useState } from "react";
const ENDPOINT = "https://formgong.com/submit";
const KEY = "fk_your_access_key";
const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
const RULES = {
name: (v) => (v.trim() ? "" : "Please enter your name."),
email: (v) => (!v.trim() ? "Please enter your email." : EMAIL.test(v.trim()) ? "" : "Check the email, for example emma@example.com."),
message: (v) => (v.trim().length >= 10 ? "" : "Please write at least 10 characters."),
};
const FIELDS = Object.keys(RULES);
const EMPTY = { name: "", email: "", message: "" };
// Show a message only for fields the visitor has already left (or after a submit).
function visible(errors, touched) {
return Object.fromEntries(Object.entries(errors).filter(([field]) => touched[field]));
}
function validate(values) {
const errors = {};
for (const field of FIELDS) {
const message = RULES[field](values[field]);
if (message) errors[field] = message;
}
return errors;
}
// Formgong answers a failed field check with 422 and errors: [{ field, code }].
function fromServer(list) {
const errors = {};
for (const { field, code } of list) errors[field] = code === "required" ? "Please fill this in." : `This is not a valid ${code}.`;
return errors;
}
export default function ContactForm() {
const [values, setValues] = useState(EMPTY);
const [errors, setErrors] = useState({});
const [touched, setTouched] = useState({});
const [status, setStatus] = useState("");
const [sending, setSending] = useState(false);
const inputs = { name: useRef(null), email: useRef(null), message: useRef(null) };
function focusFirst(found) {
const first = FIELDS.find((field) => found[field]);
if (first) inputs[first].current.focus();
}
function onChange(event) {
const next = { ...values, [event.target.name]: event.target.value };
setValues(next);
// Re-check only fields the visitor has already left, so nobody is scolded mid-word.
setErrors(visible(validate(next), touched));
}
function onBlur(event) {
const nextTouched = { ...touched, [event.target.name]: true };
setTouched(nextTouched);
setErrors(visible(validate(values), nextTouched));
}
async function onSubmit(event) {
event.preventDefault();
if (sending) return;
const found = validate(values);
setErrors(found);
setTouched({ name: true, email: true, message: true });
if (Object.keys(found).length) return focusFirst(found);
setSending(true);
setStatus("Sending…");
try {
const response = await fetch(ENDPOINT, {
method: "POST",
headers: { Accept: "application/json" },
body: new FormData(event.currentTarget),
});
const data = await response.json().catch(() => ({}));
if (response.ok && data.success) {
setValues(EMPTY);
setTouched({});
setStatus("Thanks, your message was sent.");
} else if (Array.isArray(data.errors)) {
const serverErrors = fromServer(data.errors);
setErrors(serverErrors);
focusFirst(serverErrors);
setStatus("Please fix the marked fields.");
} else {
setStatus(data.message || `Not sent (error ${response.status}). Please try again.`);
}
} catch {
setStatus("Not sent: check your connection and try again.");
} finally {
setSending(false);
}
}
const field = (name) => ({
id: name,
name,
ref: inputs[name],
value: values[name],
onChange,
onBlur,
"aria-invalid": errors[name] ? "true" : "false",
"aria-describedby": `${name}-error`,
});
// The slot is always there (min-height in CSS), so a message appearing or clearing never moves the Send button.
const error = (name) => <p id={`${name}-error`} className="error">{errors[name] ?? ""}</p>;
return (
<form onSubmit={onSubmit} noValidate>
<input type="hidden" name="access_key" value={KEY} />
<input type="text" name="botcheck" tabIndex={-1} autoComplete="off" style={{ display: "none" }} />
<label htmlFor="name">Name</label>
<input {...field("name")} autoComplete="name" required />
{error("name")}
<label htmlFor="email">Email</label>
<input {...field("email")} type="email" autoComplete="email" required />
{error("email")}
<label htmlFor="message">Message</label>
<textarea {...field("message")} rows={5} required minLength={10} />
{error("message")}
<button type="submit" disabled={sending}>{sending ? "Sending…" : "Send"}</button>
<p role="status">{status}</p>
</form>
);
}
What happened when we ran it?
We built the component with esbuild, opened it in Chromium on our test server and posted it to a local copy of Formgong's form backend, the same code that runs at formgong.com. One form there had no field checks, the other had name, email and message set as required, with the email checked as an email.
| Case | What happened |
|---|---|
| Empty form | 3 messages, focus on Name, 0 requests |
Spaces as the name, emma@, “Hi” | 3 messages, focus on Name, 0 requests |
emma@example as the email | 1 message, focus on Email, 0 requests |
Typing emma@, then leaving the field | No message while typing, one after leaving |
| A correct form | 1 request, 200, fields cleared, message stored and emailed |
| React checks off, form with field checks on the server | 1 request, 422, Email and Message marked from the server's answer |
| React checks off, form without field checks | 1 request, 200, an empty name and emma@example stored |
| Wrong access key | 1 request, 404, “That access key does not exist.”, fields kept |
| Browser offline | “Not sent: check your connection”, fields kept |
The first four rows never reached the network. That is the point of checking in the browser, because the visitor gets an answer at once and you get no junk. The last two rows are about what the form does when the problem is not the visitor's typing. A wrong key or a dropped connection must not wipe what they wrote, and the message has to say what to do next. Our article on “Failed to fetch” on contact forms covers the network failures in more detail.
Why check the fields again on the server?
Everything in the browser can be skipped. A bot posts straight to your endpoint, and a visitor with an old browser or a blocked script sends whatever is in the boxes. We switched the React checks off and posted emma@example with an empty name and message to both forms.
The form without field checks stored it and emailed a notification with an empty name. The form with field checks answered 422 with a list of the fields that failed, [{"field":"email","code":"email"},{"field":"message","code":"required"}], and stored nothing. The component reads that list and puts “This is not a valid email.” under the email field, exactly where a browser-side message would go. You write the field rules once on the server and still show the visitor where to look.
Spam is a separate job from validation. The hidden botcheck field in the component is a honeypot, and our honeypot guide explains why bots fill it in and people never see it. If the same person clicks Send twice, the disabled button stops the second request; duplicate submissions covers the rest.
Do you need React Hook Form or Zod?
For a contact form with three to ten fields, no. The component above is about a hundred lines and has no dependency to update. A library starts to pay off when you have many forms, steps, fields that depend on each other, or one schema you want to share between the browser and your own server.
If you do use one, keep the two habits that mattered in our test. Trim before you check, because a schema with min(2) accepts two spaces as a name. And handle the failure branch, so a server error lands on a field instead of disappearing. Splitforms' React form validation guide (last reviewed 15 May 2026), which uses React Hook Form with Zod and which we read on 3 November 2026, leaves both out: its schema has no trim, and its code does nothing when the send fails. Their newer blog post on React Hook Form and Zod does trim and does handle a failed send. If you are on React 19 and prefer form actions, our useActionState contact form shows the same send with a different state model.
How does this work with Formgong?
Formgong is a form backend. Your form posts to https://formgong.com/submit with your access key, and the message reaches your email and Telegram. Under Settings → Protection → Field checks you mark fields as required or as an email, URL, number, date or phone number, and Formgong refuses a post that breaks one with a 422 that names each field, before anything is stored or counted. That is the answer the component maps onto its fields.
Field checks are on every plan, Free included. Of the three competitor guides we read on 3 November 2026, Formspree's says its React library picks up validation errors from Formspree's server, though its plans page does not list field validation, so we cannot tell you which plans have it. The Splitforms and Static Forms guides do not describe any server-side field check by their own service; the Static Forms one tells you to validate on your own server. If you would rather start from finished code, the React contact form component page has a copy-paste version, and the HTML forms docs list every field Formgong reads.
Did your form fail in a way we missed?
If your React form lets through something this test did not cover, or the component misbehaves in your setup, write to us at support@formgong.com. We will run your case and add it here.
Frequently asked questions
Does required stop empty fields in React?
Not fully. The browser treats a value of spaces as filled in, so trim the value in your own check before deciding it is empty.
Why does type=email accept an address without a dot?
The HTML standard allows addresses like emma@example. If you want a dot after the @, check it yourself and on the server.
Should I validate on change or on blur?
Show a field's message after the visitor leaves it, then update it as they type. Showing it earlier scolds people mid-word.
Is client-side validation enough?
No. Anyone can post to your endpoint without running your JavaScript, so the server has to check the fields again.
Sources and documentation
Official references for this guide: Formgong: React 19 contact form with useActionState, Formgong: Accessible contact form. HTML forms, where data is stored.
Related guides
- Lovable form submissions to email and Telegram
- HTML contact form without a backend: a working example
- How to send website form submissions to Telegram
- Contact form not sending email? Check where it stops
- Managing website leads in Telegram without a CRM
- Form backend for Lovable, Bolt, v0, Cursor
- Telegram bot for a contact form: build or skip?
- GDPR form backend: 7 checks before you choose
- Lovable form not sending email? 6 fixes
- Netlify Forms not working? React and Bolt fixes
- Stop contact form spam without a CAPTCHA
- GitHub Pages contact form: a working setup
- Mailto Form in HTML: Why It Fails and What to Use
- HTML form to Google Sheets: 2 free methods
- Webflow form submission limit: what to do at 50
- Turnstile vs reCAPTCHA vs hCaptcha for forms
- Contact Form 7 and Elementor forms to Telegram
- Squarespace contact form not sending email?
- Shopify contact form: where do messages go?
- Google Form to Telegram: free Apps Script way
- Wix contact form not sending email? Fixes
- EU / GDPR Formspree alternatives compared
- HTML form action attribute explained
- How do HTML forms work? The HTTP request
- Types of Injection Attacks on Web Forms (2026)
- Indirect Prompt Injection in MCP
- MCP Rug Pull Attack: Detect Tool Changes
- Form without a backend: 7 ways that work
- Thank-you page after form submission (HTML)
- Indirect Prompt Injection Examples (2023–2026)
- Indirect Prompt Injection via Email
- What Is Tool Poisoning in MCP?
- WordPress contact form without a plugin
- Send email from frontend JavaScript
- How to Prevent Indirect Prompt Injection
- Honeypot Form Field: How to Add One That Works
- Contact Form with File Upload (HTML, No PHP)
- Angular contact form without a backend
- Send form submissions to Slack or Discord without Zapier
- Verify a form webhook signature (HMAC-SHA256)
- Contact forms that send nothing: 793 AI-built sites tested
- v0 contact form that actually sends: 3 ways
- How we tested AI-built contact forms, and 12 bugs we hit
- Cloudflare vs Netlify free plan: hosting that never pauses
- EmailJS 412 “Gmail_API: Invalid grant”: reconnect Gmail
- Resend “You can only send testing emails”: verify a domain
- Supabase Edge Function blocked by CORS policy: 3 causes
- Formspree “Form not found” and other errors: fixes
- Web3Forms errors: “Invalid access key” and 403 explained
- How to add customer reviews to your website for free
- Getform not working? “This form has been deleted” and more
- Next.js contact form not working? 6 errors, reproduced
- Webflow form not sending email? What to check, tested
- FormSubmit not working? “This form needs Activation” fix
- Contact form “TypeError: Failed to fetch”: causes and fixes
- WooCommerce product enquiry form
- Contact Form 7 vs WPForms
- Gravity Forms alternative free
- WordPress contact form block
- 535-5.7.8 Username and Password not accepted (Gmail)
- 535 5.7.3 Authentication unsuccessful: Office 365 SMTP
- Nodemailer “Missing credentials for "PLAIN"”: the fix
- Nodemailer “Greeting never received”: port 465 fix
- Nodemailer SSL “wrong version number”: the port fix
- Nodemailer “self-signed certificate in certificate chain”
- Nodemailer ECONNREFUSED 127.0.0.1:587: missing SMTP host
- SendGrid “authorization grant is invalid”: 401 fix
- Mailgun 401 Forbidden: why the API rejects your key
- “Edge Function returned a non-2xx status code”: the fix
- Next.js “Body exceeded 1 MB limit”: Server Action fix
- Unexpected token '<', "<!DOCTYPE "... is not valid JSON
- “TypeError: Body is unusable”: body has already been read
- Turnstile “timeout-or-duplicate” and other siteverify errors
- Turnstile vs hCaptcha vs reCAPTCHA: speed and size tested
- Judge.me reviews not showing on Shopify: how to fix it
- Judge.me review carousel not showing: how to fix it
- Yotpo reviews not showing on Shopify? Check the app embed
- Loox reviews not showing on product page: how to fix
- Shopify reviews not showing: what to check first
- How to show reviews on Shopify
- GDPR for website forms: what each type of form needs
- WooCommerce reviews not showing: how to fix it
- Stamped.io reviews not showing on Shopify: how to fix it
- Etsy reviews not showing: why and what to do
- Trustpilot widget not loading: how to fix TrustBox
- Yotpo problems in 2026: what merchants report
- Contact Form 7 “error trying to send your message” fix
- Elementor form “Your submission failed because of an error”
- Framer form not sending email or not working: what to check
- Carrd contact form not working: plans, spam and errors
- Google review link not working: what customers see and why
- tawk.to widget not showing on your website: causes and fixes
- How to add questions and answers to your product page
- “Failed to send a request to the Edge Function”: fixes
- Next.js “Failed to find Server Action”: what it means
- Brevo “unauthorized: Key not found” 401: the fix
- Amazon SES “Email address is not verified”: the fix
- Shopify contact form not working: how to fix it
- Judge.me alternative for WooCommerce after the 2025 shutdown
- Free WooCommerce review plugins compared on the free version
- WooCommerce review reminder emails without a paid plugin
- Add Voice Recording to a Website Form
- Contact Form 7 spam: how to stop it
- WPForms not sending email: how to fix it
- Contact form emails going to spam: how to fix it
- HTML form not submitting: how to fix it
- Contact form not working: how to find the fault
- Webflow form spam: how to stop it
- Website form to Notion: how to set it up
- Website form to WhatsApp: what works and what does not
- What 1-star reviews say about AI support chatbots
- Which free form backend gives you the most submissions?
- Elfsight reviews widget not showing? Check the view limit
- Next.js contact form backend vs Server Actions
- Review stars not showing in Google search results
- How to stop duplicate form submissions
- How to see which form leads came from ChatGPT
- What happens when a form webhook fails
- When to send a review request email after an order
- How to collect video testimonials for free
- Add contact form sign-ups to Mailchimp or Klaviyo
- How to migrate from Formspree without losing submissions
- How to get a Google review link for your business
- What is a headless form backend?
- Is it safe to put a form access key in your HTML?
- AI chatbot that answers only from your website
- Minified React error #441 in Next.js
- Squarespace product reviews after Judge.me
- Accessible contact form checklist for WCAG 2.2
- How to ask a client for a testimonial by email
- How to respond to negative reviews, with examples
- 429 Too Many Requests on a contact form
- MCP server for forms in Cursor and Claude
- Can you offer a discount for a review?
- Do EU stores have to say if reviews are verified?
- Webflow form backend options compared
- How to add review schema JSON-LD to a product page
- How to turn a customer review into an Instagram post
- How to make a QR code for Google reviews
- Live chat or chatbot for a small business website
- Why people abandon your contact form halfway
- Which form backend do AI assistants pick? 54 answers
- PHP mail() not sending email, even when it returns true
- What “Failed to fetch” means, tested in three browsers
- 405 Method Not Allowed when you submit a form
- Send a contact form to more than one email address
- What is review syndication, and who needs it?
- How to save HTML form data to a database
- NetworkError when attempting to fetch resource
- Send product reviews to Google Merchant Center
- PHPMailer not working on a live server
- AI review reply generator: does it help?
- React 19 contact form with useActionState
- Astro Actions or a form backend?
- Is no-reply@wixsiteautomations.com legit?
- Where to find the Judge.me review widget code
- AI review summaries: what shoppers actually see
- Photo reviews for WooCommerce, and the GPS inside them
- Review request email templates you can copy
- Reviews in AI search: what ChatGPT and Perplexity cite
- Lead capture form with UTM tracking, built and tested
- Form design best practices, with our own form data
- Client intake form template with file upload
- What is social proof? Meaning and examples
- What is user-generated content (UGC)?
- Benefits of negative reviews for your store
- How to get your first reviews as a new store
- How to use customer reviews in your marketing
- How to get more customer reviews
- jQuery submit form with validation
- reCAPTCHA v3 setup with the server score check
- Shopify social proof that shoppers can check
- HTML file input: accept, multiple, capture and size checks
- How to add hCaptcha to a form, with the server check
- How to add invisible reCAPTCHA to a form
- Bug report form template with browser details
- What the FTC fake reviews rule bans for online stores
- How to show reviews on your homepage
- Do reviews increase sales? What the studies show
- HTML input types and what each one sends
- HTML textarea, tested in a real form
- HTML dropdown menu in a form, tested
- Do reviews help SEO? What Google says and shows
- How to add a review carousel people can read
- Product review examples that help shoppers decide
- Which trust badges actually mean something
- Customer satisfaction survey with CSAT and NPS
- JavaScript FormData and what fetch actually sends
- JavaScript form validation without a library
- Server-side form validation and what it catches
- Email validation in JavaScript, tested on 33 addresses
- Zod form validation with FormData, tested
- Store reviews vs product reviews
- How to send review requests through Klaviyo
- How to tag customer reviews by topic and mood
- Custom review form questions worth asking
- Online reputation management for small businesses
- HTML radio button groups and what they send
- HTML label tag and what screen readers hear
- HTML autocomplete attribute, tested with Chrome autofill
- HTML fieldset and legend, and what disabled leaves out
- HTML button tag and what a form button sends
- Vite contact form that still works after the build
- How to test a contact form, end to end
- How to embed a Google Form, and what it loads
- Customer feedback questions that get real answers
- How to convert a file to base64 in JavaScript
- FilePond with a form backend, and when to skip it
- Bootstrap form validation and server errors
- Tailwind form validation, tested in three browsers
- Donation form in HTML, and where the payment goes
- How to ask for a review in person or by text
- Which review sites matter for your business
- What are customer reviews, and which kinds count
- Online review statistics, checked at the source
- Best review app for Shopify and WooCommerce
- Why Gmail sends your self-hosted mail to spam
- htmx contact form that sends to another domain
- AI form builders tested, from prompt to sent form
- Headless WordPress forms with Contact Form 7, tested
- React Hook Form watch vs useWatch, and what gets sent
- Elfsight widget not working? It vanishes when views run out
- Jotform not sending emails? Check Jotform's bounce list
- Typeform not working? A white box means a blocked script
- Positive review response examples that don't sound copied
- How to remove a Google review when you can't delete it
- Google reviews not showing up? 8 causes to check in order
- Is buying Google reviews illegal? Even a review swap counts
- Which reviews can you hide? A review moderation checklist
- Average star rating: what 4.8 from 5 reviews means
- Reviews on a product page: where and how many to show
- SaaS testimonials: 3 of 27 had a number in them
- Do reviews reduce returns? Not when they're too good
- Testimonial examples for business: what makes one believable
- Testimonial questions to ask clients, by type of business
- Testimonial page design: a page or a section?
- Testimonial advertising rules: what the FTC requires
- Form submission canceled because the form is not connected
- Input type date format dd/mm/yyyy: what you can change
- How to disable textarea resize, or allow only vertical
- How to prevent Enter from submitting a form
- form.submit() vs requestSubmit(): what submit() skips
- Custom HTML checkbox CSS that doesn't break required
- How to reset a form after submit, and what reset() keeps
- Input type number maxlength not working? What to use
- How to create an HTML form, step by step
- Best form builder: free plans and branding, checked
- Best WordPress contact form plugin: 10 free ones compared
- How to increase form conversion rate: start with the count
- Form backend vs form builder: which one do you need?
- WordPress contact form not sending email? 3 plugins tested
- Contact Form 7 webhook? Turning it on switched our email off
- Gravity Forms webhook: what it sends and the URLs it rejects