-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.js
30 lines (25 loc) · 1.21 KB
/
auth.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
document.getElementById('login-form').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the default form submission behavior
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
// Example validation for username and password
if (username.length >= 3 && password.length >= 6) {
// Assuming login is successful
displayLoginNotification('Login successful', 'success');
// Redirect to index.html after a short delay
setTimeout(() => {
window.location.href = 'index.html'; // Redirect to homepage
}, 1000); // 1-second delay to allow the user to see the success message
} else {
displayLoginNotification('Invalid username or password', 'error');
}
});
function displayLoginNotification(message, type) {
const notification = document.getElementById('login-notification');
notification.textContent = message;
notification.className = type === 'success' ? 'notification success' : 'notification error';
notification.classList.remove('hidden');
setTimeout(() => {
notification.classList.add('hidden');
}, 3000);
}