forked from cringy-beaver/front
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_scripts.js
28 lines (24 loc) · 1.11 KB
/
common_scripts.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
const form = document.getElementById('login-form');
const loginInput = document.getElementsByName('text_login')
const passwordInput = document.getElementsByName('text_password')
// const usernameInput = document.getElementById('username');
// const passwordInput = document.getElementById('password');
const loginBtn = document.getElementById('login-btn');
loginBtn.addEventListener('submit', function(event) {
event.preventDefault();
const username = usernameInput.value;
const password = passwordInput.value;
if (username === 'admin@test.ru' && password === 'password') { //TODO: заменить на проверку в базе данных
alert('Вход выполнен успешно!');
} else {
alert('Неправильные имя пользователя или пароль.');
usernameInput.classList.add('error');
passwordInput.classList.add('error');
}
});
usernameInput.addEventListener('input', function() {
usernameInput.classList.remove('error');
});
passwordInput.addEventListener('input', function() {
passwordInput.classList.remove('error');
});