-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (48 loc) · 2.32 KB
/
index.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Handle login
document.addEventListener('DOMContentLoaded' ,function(){
let front = document.querySelector('.containerFront');
let back = document.querySelector('.containerBack');
let newUser = document.querySelector('.newUser');
let existingUser = document.querySelector('.existingUser');
newUser.addEventListener('click' , function(){
front.style.zIndex = "1"
back.style.zIndex = "2"
front.style.transform = "rotateY(180deg)"
back.style.transform = "rotateY(0deg)"
})
existingUser.addEventListener('click' , function(){
back.style.zIndex = "1"
front.style.zIndex = "2"
back.style.transform = "rotateY(180deg)"
front.style.transform = "rotateY(0deg)"
})
const loginForm = document.querySelector('.containerFront form');
const registerForm = document.querySelector('.containerBack form');
// Simulate a user login by checking if inputs are filled (for demo purposes)
loginForm.addEventListener('submit', function(e) {
e.preventDefault(); // Prevent form submission
const username = document.querySelector('.input').value;
const password = document.querySelector('.input1').value;
if (username && password) {
// Simple check for demo purposes, can be replaced by an actual validation process.
console.log('Login successful');
window.location.href = 'dashboard.html'; // Redirect to dashboard
} else {
alert('Please enter both username and password.');
}
});
// Handle registration
registerForm.addEventListener('submit', function(e) {
e.preventDefault(); // Prevent form submission
const name = document.querySelector('.register-input').value;
const email = document.querySelector('.register-input1').value;
const password = document.querySelector('.register-input2').value;
if (name &&email && password) {
// Simple check for demo purposes, can be replaced by an actual registration process.
console.log('Registration successful');
window.location.href = 'dashboard.html'; // Redirect to dashboard
} else {
alert('Please fill in all fields.');
}
});
});