(Note · · 5 min read)
The form threw away ten minutes of work
Someone fills in a long form, submits it, and the page returns with an error and several fields empty. Nothing crashed. The form worked exactly as written — and the person now has to retype what they already typed, which is the point at which most of them leave instead.
By Md. Habibur Rahman Shohel, full-stack & AI product engineer in Dhaka
Never discard input on error
Whatever the validation outcome, every value the user entered comes back. This sounds obvious and is violated constantly — most often by clearing a password field on an unrelated error, or by resetting a form after a failed network request.
If a submission fails for a reason the user cannot fix, such as a server being down, keep the data and say so. Discarding their work because your server had a bad moment is the least defensible version of this.
Validate at the right moment
Telling somebody their email is invalid after two characters is noise. Validate a field when they leave it, re-validate as they fix an error that is already showing, and check everything on submit.
That sequence means a person is never told they are wrong before they have finished being right, and gets immediate confirmation once they have corrected something.
Errors go next to the field and say what to do
A summary at the top of a long form leaves the user hunting. Put each message beside its field, keep a summary only as a way to jump to the first problem, and move focus there on submit.
Say what is expected rather than what is wrong: the required format, the allowed range, the length. Invalid input describes the system's opinion; needs at least eight characters tells somebody what to type.
Accept what people actually enter
Spaces in a card number, dashes in a phone number, a pasted value with trailing whitespace, a name with an apostrophe or a non-Latin script. These are not errors — they are how people type, and normalising them is three lines of code.
Be especially careful with names, addresses and identifiers from outside your own country. A validation rule written around one national format rejects legitimate customers, and they do not report it, they leave.
Make submission safe to repeat
Disable the button while a request is in flight and show that something is happening. Then, because disabling a button is an interface courtesy rather than a guarantee, make the endpoint idempotent so a retry cannot create a second record.
Keep the timeout explicit and recoverable: on failure, leave the form intact with its values, show what happened, and let them try again without losing anything.
Preserve long work across a lost page
For anything substantial, keep a draft in local storage as it is typed and restore it on return. Phones run out of battery and tabs get closed, and this is a handful of lines that converts a lost afternoon into an inconvenience.
Clear the draft on successful submission, and keep anything sensitive out of it — a half-finished form holding identity details in a shared browser is a privacy problem that outlives the session.
Use the platform
Correct input types bring the right keyboard on a phone, autocomplete attributes let a password manager fill the form, and real labels make it usable with a screen reader and give a larger tap target. Each is one attribute.
Then test with the keyboard alone, and on a phone. Most form problems are discovered in the first thirty seconds of either, and almost never by the person who wrote it on a desktop with a mouse.
Common questions
Why do users abandon forms?
Most often because the form discarded what they typed — fields cleared after a validation error or a failed network request. Every value should come back whatever the outcome, and a submission that fails for a reason the user cannot fix should keep their data and say so.
When should form fields be validated?
When the user leaves a field, then continuously while they fix an error already showing, and fully on submit. Validating as they type tells people they are wrong before they have finished being right.
How should validation messages be written?
Next to the field, saying what is expected rather than what is wrong — the required format, range or length. Move focus to the first problem on submit, and use a summary only as a way to jump there.
How do I stop long forms losing work?
Keep a draft in local storage as the user types and restore it on return, clearing it on success. Keep sensitive values out of the draft, since a half-finished form holding identity details in a shared browser outlives the session.