01"Invalid input" is a dead end

Most validation errors fail the user before the form does. They confirm something went wrong without saying what, where, or how to fix it. That turns a fixable typo into a support ticket or an abandoned form.

A good error message answers three questions in order: what's wrong, where it is, and what to do next. Drop any one of those and the user is left guessing, which is exactly the state validation was supposed to prevent.

02The patterns that separate helpful from hostile

  1. 01

    Validate on blur, not on keystroke

    Flagging an email as invalid after the third character punishes someone mid-typing. Wait until they've left the field, or until submit for fields that are cheap to get wrong.

  2. 02

    Name the field, not just the rule

    "Must be at least 8 characters" floating near three password-shaped fields is a guessing game. Anchor the message to the exact field, inline.

  3. 03

    State the fix, not just the failure

    "Invalid date" describes a symptom. "Use DD/MM/YYYY" describes a cure. The second one ends the interaction; the first one starts a support thread.

  4. 04

    Summarize on submit, detail inline

    A top-of-form summary ("3 fields need attention") helps orientation on long forms, but it should link to each field's own inline message — never replace it.

  5. 05

    Never blame the user in the copy

    "You entered an invalid value" reads like an accusation. "This field needs a value between 1 and 100" reads like information. Same rule, different relationship with the reader.

  6. 06

    Preserve what the user already typed

    Clearing a field on error and forcing a retype is the fastest way to make a form feel punitive. Keep the value, fix the one thing that's wrong.

03Server errors deserve the same care as client ones

Client-side validation gets the design attention; server-side failures (a duplicate record, a stale reference, a permission the UI didn't know about) often get dumped as a raw API message or a generic "Something went wrong." That's the exact moment a user is most likely to give up, because it happens after they've already committed to submitting.

Map server error codes to the same three-question format as client errors: what's wrong, where, what to do. If the mapping doesn't exist yet, that's the gap most worth closing before adding another field-level validator.

04One error component, every form

The cheapest way to keep error copy consistent in Angular is to stop writing it in templates. A small FieldErrorComponent reads the control's ValidationErrors and maps each key to a message that names the field and states the fix.

Server-side errors go through the same path: when the API rejects a value, call control.setErrors({ server: message }) and the same component renders it inline. The user's input stays untouched, and nothing is cleared on failure.

field-error.component.ts
@Component({
  selector: 'app-field-error',
  template: `
    @if (control().invalid && control().touched) {
      <p class="field-error" [id]="id()" role="alert">{{ message() }}</p>
    }
  `,
})
export class FieldErrorComponent {
  control = input.required<AbstractControl>();
  label = input.required<string>();
  id = input.required<string>();

  message() {
    const e = this.control().errors ?? {};
    if (e['required']) return `Enter ${this.label().toLowerCase()}.`;
    if (e['email']) return 'Use an email like name@company.com.';
    if (e['server']) return e['server'];
    return `Check ${this.label().toLowerCase()}.`;
  }
}

The takeaway

An error message is a design surface, not an afterthought. Validate at the right moment, name the field, state the fix, and never blame the user — and most "form errors" stop being errors at all, just quick corrections on the way to submit.

Written by Jaymin MahetaSenior UI/UX Developer turning Figma designs into fast, accessible enterprise apps in Angular and React.
About me →