Prevent Duplicate Form Submissions: 4 Fixes That Actually Work

Stop double clicks, refreshes and retries from sending the same form twice. Disabled buttons, Post/Redirect/Get, request locks and idempotency keys, with code.

· 3 min read

A form button showing a sending state to prevent double clicks

You get the same enquiry twice, sometimes three times, a few seconds apart. It is not spam; it is a real person who double-clicked, hit refresh or pressed Send again because nothing seemed to happen. Duplicates are annoying in your inbox and worse in your follow-up: two teammates may reply to the same lead.

Here is why they happen and how to stop them.

Why duplicates happen

CauseWhat the visitor did
Double clickClicked the button twice quickly
No feedbackWaited, saw nothing, clicked again
Slow networkRequest still in flight, pressed again
Refresh after POSTBrowser re-sent the form ("Confirm form resubmission")
Back buttonReturned to the form and submitted again
Automatic retriesA script retried after a timeout, but the first request had succeeded

Fix 1: Disable the button while sending

The single most effective fix. Disable the submit button the moment the request starts and show that something is happening:

js
form.addEventListener('submit', async (e) => {
  e.preventDefault();
  const btn = form.querySelector('[type="submit"]');
  if (btn.disabled) return;           // already sending
  btn.disabled = true;
  btn.textContent = 'Sending…';
  try {
    const res = await fetch(form.action, { method: 'POST', body: new FormData(form) });
    const data = await res.json();
    if (!data.success) throw new Error(data.message);
    form.replaceWith(Object.assign(document.createElement('p'), { textContent: 'Thanks! Message sent.' }));
  } catch (err) {
    btn.disabled = false;             // allow a retry only on failure
    btn.textContent = 'Send';
    alert(err.message || 'Something went wrong.');
  }
});

Replacing the form with the success message (instead of only resetting it) also removes the temptation to submit again.

Fix 2: Post/Redirect/Get for non-JavaScript forms

If a plain HTML form posts and the server responds with a page directly, refreshing that page re-sends the POST. The fix is Post/Redirect/Get: after a POST, redirect to a normal GET page (a thank-you page). Refreshing the thank-you page is harmless.

Formiz does this for you. A standard form post gets a 303 See Other redirect to a thank-you page (or your own redirect URL), so refresh and back-button resubmissions do not happen.

Fix 3: Give immediate feedback

Many duplicates come from uncertainty, not impatience. Show "Sending…" instantly, and on success show a message that clearly says it worked and what happens next. See thank-you pages and inline messages.

Fix 4: Do not retry blindly

If you add automatic retries for flaky networks, only retry when you are sure the first request failed (no response at all), and never after a timeout without a way to deduplicate. Otherwise a slow-but-successful request plus a retry equals two submissions.

Fix 5: Idempotency keys (for your own backend)

If you run your own endpoint, generate a unique ID when the form loads and send it with the submission:

html
<input type="hidden" name="submission_id" id="submission_id">
<script>document.getElementById('submission_id').value = crypto.randomUUID();</script>

On the server, store processed IDs and ignore repeats. This is the robust solution for payments and orders; for contact forms, fixes 1–3 are usually enough.

Fix 6: Rate limiting as a safety net

A burst of identical submissions from one source is also a classic bot pattern. Formiz rate-limits repeated submissions from the same visitor within a short window, which catches runaway scripts and frantic clicking alike.

Checklist

  • Submit button disabled while sending
  • "Sending…" feedback within 100 ms
  • Form replaced by a clear success message
  • Non-JS posts use Post/Redirect/Get
  • No blind retries after timeouts
  • Rate limiting on the receiving end

Related: submit a form with fetch and FormData.

Get your form working in five minutes

Create a free Formiz key, add it to your form and receive submissions by email and Telegram. No server, no SMTP, no card.