StaffCoder
TypeScript
Vanilla TypeScriptTypeScript 7.0
6 modules · 24 challengesSign up
Module 3 · Forms & Input Handling

Member Signup Form

easyPure per-field validation returning a typed error map0%0 of 1 solved

Problem statement

A small signup form with four fields. Each field must show its own message next to it after the person leaves that field, and the submit button must stay off until every field is good. When the form is finally good and submitted, the fields empty out and a success banner appears.

Demo

The page, styles, form markup, labels, message paragraphs, submit button, and success banner are already scaffolded and wired. Only the validate function in src/js/validation.ts and the renderFieldError, renderSubmitEnabled and renderSuccess functions in src/js/render.ts are missing — implement them so every test passes. Do not edit any other file.

What to implement

  • Show a short reminder next to the name box if the person leaves it blank.
  • Show a short reminder next to the email box if the email does not look like a real email address.
  • Show a short reminder next to the password box if the password is too short.
  • Show a short reminder next to the confirm-password box if it does not match the password, and never show that reminder next to the password box.
  • Only show a box's reminder after the person has left that box for the first time — before that, keep the space beside the box empty.
  • While a reminder is showing, make the box read as invalid for screen readers and tie the box to its reminder; take those cues off again once the box is fixed.
  • Keep the Create account button switched off while any of the four boxes still has a problem, and switch it on only when all four are fine.
  • If the person tries to submit while something is still wrong, reveal a reminder next to every box that has a problem, keep the form filled in, and do not show the success banner.
  • When the person submits a form where everything is fine, empty all four boxes, clear every reminder, switch the button back off, and reveal the success banner.
  • Everything shown must come from checking the four values you were given — nothing should be hardcoded.

More in Forms & Input Handling

See the module
Insurance Quote Form Implement visibleFieldNames, validate, renderGroups, renderFieldError, and renderPayload. The insurance-type select reveals one of three groups (Auto / Home / Life); switching type clears the previously visible group's inputs; validation reports errors only for currently visible fields; a valid submit renders a JSON payload with the common fields plus the visible group's fields only.0%0 of 1 solvedeasyProfile Settings Editor Implement isDirty, validate, and the render helpers (renderValues, renderFieldError, renderSaveEnabled, renderSavedFlash). Save enables the moment values diverge from the baseline and disables when they match again; a valid save promotes current values to the new baseline; Reset restores the baseline; and the browser's beforeunload prompt fires only while the form is dirty.—No data yeteasyStudio Booking SubmissionImplement validate, buildPayload, and the renderFieldError, renderFormDisabled, renderSubmitError, renderConfirmation helpers. On submit, the form validates, normalises raw inputs (trimmed strings, numeric fields as number, ISO date passthrough), disables every input while awaiting window.submitBooking(payload), and either reveals a confirmation with the returned reference or re-enables the form and surfaces the rejection message with typed values preserved.—No data yeteasy

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.