Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Form loses entered data on validation error: how to fix it

PRF-216High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

A visitor fills in a form, presses the button, and one field fails a check. Maybe the phone number has a space in it, or a required box was skipped. The page shows an error, and the fields they filled correctly are now empty.

This usually has one of three causes. The form does a full page reload and the server sends back a blank form. A script calls form.reset() after any response, including an error. Or a framework re-renders the form and drops its values. It differs from an error that appears only after submit (PRF-215), because here the real damage is the lost data.

Why it costs you leads or sales

Typing is the hard part of a form, especially on a phone. Asking someone to do it twice for a mistake in one field feels like a punishment. Many will not try again, and you never see them, because the lead was lost before it reached your inbox or CRM.

It also hurts the longest forms most: checkout addresses, quote requests and booking forms, where the visitor has put in the most effort.

Visitors who finish after a validation errorExample numbers
Visitors who finish after a validation error (example)Data kept: 70 %; Data wiped: 35 %027547035Data keptData wiped%

Example: illustrative numbers only. Of 100 visitors who hit an error, more finish when their data is kept.

Where the lead is lost
  1. Fills formVisitor types every field
  2. SubmitsOne field fails a check
  3. Error shownAll fields come back empty
  4. RetypesMost visitors give up here
  5. Lead receivedNever arrives

The break happens when the error page comes back with empty fields.

How to check if your site has it

Test your own form in five minutes
  1. Fill every field

    Use realistic test data, including a message or free-text box.

  2. Trigger one error on purpose

    Enter an invalid email such as name@ or leave a required field empty. Try a bad phone number too if there is one.

  3. Submit and look at the other fields

    Check that every other field still holds what you typed, including dropdowns, checkboxes, radio buttons and text areas.

  4. Repeat on a phone

    Use a real phone or browser device mode. Mobile browsers and autofill can behave differently.

  5. Test with scripts blocked or slow

    Reload with a throttled connection in the browser developer tools. A form that falls back to a full page reload often loses data.

How to fix it

The goal is simple: an error must never clear a field that was valid. The best way is to validate in the browser and never reload the page. The fallback is to put the submitted values back when the server sends the form again.

Fix by platform
  1. Find which form plugin you use

    Contact Form 7, WPForms, Gravity Forms, Fluent Forms and Elementor forms all keep values by default when AJAX submission is on.

  2. Turn on AJAX submission

    In the form's settings, enable AJAX (in Gravity Forms it is on the form embed or shortcode, ajax="true"). A page reload is the most common cause.

  3. Look for caching or optimisation clashes

    Deactivate caching, minify and JavaScript delay plugins one at a time and retest. They can break the form script so it falls back to a reload.

  4. Check custom code

    Search your theme or child theme for form.reset() or custom success handlers that run on errors too.

Keep values on error, reset only on successjavascript
const form = document.querySelector('#lead-form');
form.addEventListener('submit', async (e) => {
  e.preventDefault();
  if (!form.checkValidity()) {
    form.reportValidity();
    return; // fields stay filled
  }
  const res = await fetch(form.action, { method: 'POST', body: new FormData(form) });
  if (res.ok) {
    form.reset();
    // show thank-you message
  } else {
    // show error message, leave fields as they are
  }
});
Server-side refill (escape every value)php
<input type="email" name="email"
  value="<?php echo isset($_POST['email']) ? htmlspecialchars($_POST['email'], ENT_QUOTES, 'UTF-8') : ''; ?>">
<textarea name="message"><?php echo isset($_POST['message']) ? htmlspecialchars($_POST['message'], ENT_QUOTES, 'UTF-8') : ''; ?></textarea>
What the visitor sees

Before

  • Page reloads after submit
  • Error appears, every field is empty
  • Visitor retypes or leaves

After

  • Error appears next to the bad field
  • Everything else stays filled
  • Visitor fixes one field and sends

How to confirm it's fixed

Confirm the fix
  • Fill every field, trigger an error, and see all valid fields stay filled
  • Check dropdowns, checkboxes and radio buttons keep their choice
  • Test on a phone and in at least two browsers
  • Test with browser autofill
  • Submit a valid form afterwards and confirm the lead reaches your inbox or CRM
  • Confirm the form still clears after a successful send

How to prevent it happening again

Forms break after theme updates, plugin updates and script changes. Add a deliberate-error test to your release checklist for any change that touches a form, a checkout or a page builder template. Ask your developer or agency to keep validation in the browser by default, and to treat any full page reload on submit as a bug.

If you use session recordings or a tool like Microsoft Clarity or Hotjar, watch for sessions where a visitor submits, sees an error, then leaves. That pattern points to this issue.

How FunnelGuard handles this

FunnelGuard does not check for this yet. Checking that a form keeps entered data after a validation error is a possible future check, but it is not part of the product today.

What FunnelGuard does do nearby: a robot visitor runs your real lead form journey on a schedule from the EU or the US, checks each step, confirms the tracking hits are sent, and checks that the test lead reaches your inbox and CRM. If a form change stops submissions from working at all, that journey can fail and you get one alert with a screenshot and a likely cause, after a re-check from a second region. A form that works but wipes data after a mistake is a different problem and would not be reported.

To watch for it yourself, run the deliberate-error test above after every form or theme change, and review session recordings for visitors who hit an error and leave. The Free plan covers 1 site and 2 journeys with daily checks and no card, and every paid plan has a 3-day free trial.

Questions people ask

Why does my form clear all fields when there is an error?

Usually the form submits with a full page reload and the server returns a blank form, or a script calls form.reset() after any response. Turn on AJAX or browser-side validation, and make sure the form only resets after a successful send.

How do I keep form data after a validation error?

Validate in the browser with attributes like required and type="email", and stop the page from reloading. If the server must re-render the form, echo the escaped submitted values back into each field.

Is it normal for a password field to clear after an error?

Yes, password fields are usually cleared on purpose for security, and file inputs cannot be refilled either. Tell the visitor clearly that they need to enter these again, and keep every other field filled.

Why is my WordPress contact form losing data when I submit?

The form plugin is probably doing a full page reload, often because AJAX submission is off or a caching or JavaScript optimisation plugin broke the form script. Enable AJAX in the form settings, then disable optimisation plugins one at a time to find the clash.

Does losing form data really affect conversions?

Yes. Retyping a whole form is frustrating, especially on a phone, so many visitors leave instead. The lost leads are invisible because the form never reaches your inbox or CRM.

How do I test whether my form keeps data on error?

Fill every field, enter one invalid value such as an email without a domain, and submit. Check that all other fields, including dropdowns and checkboxes, still hold their values. Repeat on a phone.

Does FunnelGuard detect forms that lose data on errors?

No. FunnelGuard does not check this yet; it is a possible future check. It does run your real form journey on a schedule and checks that test leads reach your inbox and CRM, which catches forms that stop submitting.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: validation_keeps_input (Stage 29): fields that had a value and are empty after an invalid email.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.