-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
29 lines (25 loc) · 791 Bytes
/
main.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
const input = document.querySelector('input');
const passwords = ['user', 'wiosna', 'super'];
const messages = ['Wyjeżdżam na zawsze', 'Piękna pora roku', 'wszystko działa pięknie'];
const div = document.querySelector('div');
input.addEventListener('input', (e) => {
div.textContent = '';
passwords.forEach((password, index) => {
if (e.target.value == password) {
div.textContent = messages[index];
e.target.value = "";
}
})
})
input.addEventListener('focus', () => {
input.classList.add('active');
})
input.addEventListener('blur', () => {
input.classList.remove('active');
})
// if (e.target.value == password) {
// div.textContent = message;
// e.target.value = "";
// } else {
// div.textContent = '';
// }