The Cat Lovers' Club has opened sign-ups on its website — the join form is on the "Page" tab. Byte wants people to see right away what to fix, not get a "your application was rejected" email three days later.
Write setupSignup(). It attaches a submit (opens in a new tab) handler to the #signup form that: 1. cancels the page reload — event.preventDefault() (opens in a new tab); 2. reads the fields at the moment of submission: #username and #email without spaces at the edges, #password and #confirm as they are, and the #terms checkbox; 3. checks them: - empty name → "Enter your name"; shorter than 3 characters → "Name must be at least 3 characters"; - the email doesn't look like something@something.something (no spaces) → "That doesn't look like an email"; - password shorter than 8 characters → "Password must be at least 8 characters"; - the repeated password doesn't match → "Passwords don't match"; - the checkbox isn't ticked → "You have to promise to be nice to cats"; 4. writes each field's message into #<field>-error (for example #email-error), and an empty string for fields without an error; 5. writes into #status: "Welcome, Byte!" if there are no errors, otherwise "Fix the errors: 2" (the number of errors).
The form has novalidate (opens in a new tab): the browser's pop-up hints are off, every message is yours.