-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
26 lines (24 loc) · 947 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const form = document.querySelector("#sign-up-form");
const password = document.querySelector("#password");
const passwordError = document.querySelector("#password + .error-message");
const confirmPassword = document.querySelector("#confirm-password");
form.addEventListener("submit", (e) => {
if (password.value !== confirmPassword.value) {
e.preventDefault();
password.classList.add("error");
passwordError.style.visibility = "visible";
confirmPassword.classList.add("error");
}
else {
password.classList.remove("error");
confirmPassword.classList.remove("error");
passwordError.style.visibility = "hidden";
}
});
confirmPassword.addEventListener("input", () => {
if (confirmPassword.value === password.value) {
password.classList.remove("error");
confirmPassword.classList.remove("error");
passwordError.style.visibility = "hidden";
}
});