-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.js
26 lines (22 loc) · 1.01 KB
/
admin.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
document.addEventListener('DOMContentLoaded', () => {
const createAccountForm = document.getElementById('createAccountForm');
const userDatabase = JSON.parse(localStorage.getItem('users')) || {};
createAccountForm.addEventListener('submit', (event) => {
event.preventDefault();
const phone = document.getElementById('phone').value.trim();
const username = document.getElementById('username').value.trim();
const password = document.getElementById('password').value.trim();
if (phone === '' || username === '' || password === '') {
alert('Please fill out all fields.');
return;
}
if (userDatabase[phone]) {
alert('Account with this phone number already exists.');
} else {
// Save user to localStorage
userDatabase[phone] = { username, password };
localStorage.setItem('users', JSON.stringify(userDatabase));
alert('Account created successfully.');
}
});
});