Aabha · Learn by building

Exercise 07: Validate a local practice form

Use a copy of examples/07. Enter only invented values.

A. Explain

Why listen to submit on the form instead of only click on the submit button? Why does preventDefault not prove that a value is valid?

B. Diagnose

Remove the input listener that clears the custom name error. Trigger an empty-name error, then type Demo Visitor. Observe when the next submit refreshes it. Restore the listener so the custom state updates during correction.

C. Transfer

Add a checkbox labeled “I understand this is a local practice check” with required. Do not add a name attribute or any outgoing request. Verify empty, malformed email, whitespace name, quantity 0, quantity 1.5 and a valid synthetic submission.

Evidence

Record which case failed and the correction needed. A successful check must stay on the same page and say nothing was sent or registered.

Return to lesson · Explained answer