munders.← Back to starter questions

LWC

Research draft · Response not yet published

Showing required-field errors when an LWC button is clicked

Required lightning-input fields show errors after losing focus, but the author wants the same feedback when a custom submit button is clicked.

This page is a starting point for my own investigation. It does not yet provide a tested solution.

Read the original community question ↗

Older question with an existing answer. Useful as a focused practice topic; verify the current component behavior before publishing your own example.

What I’ll investigate

  • Create a minimal component with a required text input, an email input, and a submit button.
  • Check every input and ensure the submit handler stops before saving when any field is invalid.

Research notes

Reading notes checked on 5 December 2026. Org testing is still pending.

Reading note: the official lightning-input reference documents validity checking, displaying errors, and clearing custom errors. Keep the exercise to two inputs and one button, and distinguish displaying feedback from preventing submission. Not yet tested in an org.

My response

I haven’t written my response yet. After testing, I’ll explain the cause, the smallest fix, and how I verified it, then credit the original question and any answers I build on.

Solution or simplified workaround

Pending validation. I’ll explain when to use it, the smallest steps, the expected result, limitations, and how to undo it.

Validation

Not yet tested. I’ll record the actual results after reproducing the issue.

  • Blank required fields show visible errors on submit.
  • An invalid email prevents saving.
  • Corrected fields can submit, with keyboard-accessible labels and feedback.

Possible next step

A short LWC recipe with a before-and-after demonstration.

← Explore the other starter questions