thecodezone.
The Code Zone
← Back to the Developer Playbook

Code Zone Bug Lab / Episode 06

The Form That Accepts Blank Names

Rob submits a name made of spaces. The form welcomes nobody.

DEV-149 · Validation · whitespace · conditions15–20 minutesNo setup or account required
A spaces-only name creates an empty welcome label.
A spaces-only name creates an empty welcome label.

Your sprint ticket · In progress · DEV-149

The Form That Accepts Blank Names.

Customer report: I entered only spaces and the signup form said Welcome. It should ask for a name.

Steps to reproduce

  1. Replace the demo name with three spaces.
  2. Select Join demo.
  3. Compare the result with a real name and an empty field.

Validate a demo display name. Do not add account creation, passwords, or name-format restrictions.

Acceptance criteria

  • An empty name is rejected.
  • Spaces-only names are rejected.
  • Tabs and newlines alone are rejected by the validation function.
  • A real name is accepted, with surrounding whitespace removed.

Learning demo only. No real accounts, purchases, or external requests.

Reproduce → inspect → hypothesize → verify

Take the ticket.

Reproduce the reported behavior before editing. Read the Console and inspect the JS tab. Explain one hypothesis, make a focused change, then use Check challenge below the code screen. Edits update the preview. Reveal hints one at a time if needed.

Checking account and saved lab work…

Sign in to sync across devices

Loading the JavaScript and HTML editor…

Pass the checks or make three attempts to unlock an explained example.

Ready to test? Choose “Check challenge” after investigating.

    Open starter in a separate tab

    Code and prediction notes recover in this browser and sync when signed in. Instructor examples stay separate. Reset replaces code, not prediction notes.

    One possible solution

    Compare this approach with your own. Opening it does not change your code or mark the exercise complete.

    Use name.trim().length > 0. A nonempty string is not necessarily a meaningful name. The support code trims surrounding whitespace before displaying a valid name, and uses textContent so names are treated as text.

    Try first. Reveal one clue at a time.

    Need a lead?

    1. Inspect the raw value.

    Log JSON.stringify(name) and name.length. Spaces still count toward length.

    2. Separate text from whitespace.

    What does trim() return for a string containing only spaces?

    3. Check the normalized value.

    Reject the name when name.trim().length is zero. Keep real names with spaces inside them.

    Your lab report

    Show your reasoning.

    “I expected… I observed… The console showed… My hypothesis was… I changed… I verified…”

    Use Check challenge for automated behavior checks. Passing checks are useful evidence, not a complete code review.

    Give others room to investigate: label solutions as spoilers.

    Share your lab report on SKOOL (new tab) ↗