-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
45 lines (40 loc) · 1.31 KB
/
script.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const loginForm = document.querySelector("form");
const loginButton = document.querySelector("#login-button");
const usernameEl = document.getElementById("username");
const passwordEl = document.getElementById("password");
let isSuccess = false;
let isMoving = false;
let intervalId;
loginButton.addEventListener("mouseenter", () => {
if (!isSuccess) {
loginButton.style.background = 'red';
if (isMoving) {
loginButton.style.transform = "translateX(-120px)";
isMoving = false;
} else {
loginButton.style.transform = "translateX(120px)";
isMoving = true;
}
}
});
passwordEl.addEventListener("input", (e) => {
const username = usernameEl.value;
const password = passwordEl.value;
if (username === "varum" && password === "varum") {
isSuccess = true;
loginButton.style.transform = "translateX(0)";
loginButton.style.background = "green";
} else {
isSuccess = false;
loginButton.style.background = 'red';
}
});
loginForm.addEventListener("submit", (e) => {
e.preventDefault();
if(isSuccess){
const loginContainer = document.querySelector('.login-container')
const successContainer = document.querySelector('.success-container')
loginContainer.style.display = 'none'
successContainer.style.display = 'flex'
}
});