The Password
Now the password. Its fields have type="password", so the browser shows dots instead of what's typed. That's also why the user types the password twice: they can't see a typo, and with a typo in a new password, they couldn't sign in later.
- When the password is shorter than 8 characters, show
The password must have at least 8 characters. - When the second password isn't the same as the first one, show
The passwords don't match.
Don't trim the passwords: a space can be part of a password, and whoever chose it has to type it the same way every time.
The messages of all the fields still show at once: a user who got the user name wrong, typed a short password, and then typed it differently a second time sees three messages.
Instructions
Check the length of the password.
Check that the second password is the same as the first one.