Skip to content

Commit

Permalink
Fix Issue developer-job-simulation#5 (improve signup form validation …
Browse files Browse the repository at this point in the history
…feature request)
  • Loading branch information
JunYuHuang committed Apr 9, 2023
1 parent 14bae97 commit c3d8014
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ addEventListener("submit", (event) => {
resetMessage();

let email = document.getElementById("email").value;
const isEmptyEmail = email === "";
const isTakenEmail = usersTable.some((userObj) => userObj.username === email);

// TODO: Show Correct Status Messages on Signup Form
// 1. successful signup
// 2. empty email
// 3. taken email
// 4. repeat email
if (isEmptyEmail) {
return renderEmailEmptyError();
} else if (isTakenEmail) {
return renderEmailTakenError();
} else {
usersTable.push({ username: email });
return renderSuccess();
}
});

let toggleNav = () => {
Expand Down

0 comments on commit c3d8014

Please sign in to comment.