-
Notifications
You must be signed in to change notification settings - Fork 0
/
acc.js
25 lines (21 loc) · 893 Bytes
/
acc.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
//create account
document.addEventListener('DOMContentLoaded', () => {
const signUpBtn = document.querySelector('#sign-up-btn');
const usernameInput = document.querySelector('#username');
const passwordInput = document.querySelector('#password');
const confirmPasswordInput = document.querySelector('#password-confirm');
signUpBtn.addEventListener('click', () => {
const username = usernameInput.value;
const password = passwordInput.value;
const confirmPassword = confirmPasswordInput.value;
if (password !== confirmPassword) {
alert('Passwords do not match');
return;
}
// Register user locally
const user = { username, password };
localStorage.setItem('user', JSON.stringify(user));
// Redirect to login page
window.location.href = 'dashboard.html';
});
});