-
Notifications
You must be signed in to change notification settings - Fork 0
/
script5.js
94 lines (82 loc) · 3.04 KB
/
script5.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Function to open the password modal
function createPassword() {
// Validate registration form
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const phone = document.getElementById('phone').value;
if (name && email && phone) {
document.getElementById('passwordModal').style.display = 'block';
} else {
alert('Please fill out all fields.');
}
}
// Function to close the password modal
function closeModal() {
document.getElementById('passwordModal').style.display = 'none';
}
// Function to save the password and show success message
function savePassword() {
const password = document.getElementById('password').value;
const confirmPassword = document.getElementById('confirmPassword').value;
if (password === confirmPassword) {
// Here, you'd typically send the password to your server
alert('Password saved successfully!');
document.getElementById('passwordModal').style.display = 'none';
} else {
alert('Passwords do not match.');
}
}
// Function to open the forgot password modal
function openForgotPassword() {
document.getElementById('forgotPasswordModal').style.display = 'block';
}
// Function to close the forgot password modal
function closeForgotPasswordModal() {
document.getElementById('forgotPasswordModal').style.display = 'none';
}
// Function to send OTP for forgot password
function sendOTP() {
const email = document.getElementById('forgotEmail').value;
if (email) {
// Simulate sending OTP
document.getElementById('forgotPasswordModal').style.display = 'none';
document.getElementById('otpSection').style.display = 'block';
// In a real application, you would send an OTP to the user's email
alert('OTP has been sent to your email.');
} else {
alert('Please enter your email address.');
}
}
// Function to verify OTP and log in
function verifyOTP() {
const otp = document.getElementById('otp').value;
if (otp) {
// Simulate OTP verification
document.getElementById('otpSection').style.display = 'none';
alert('OTP verified. You can now log in.');
// Redirect to login page or perform login action
} else {
alert('Please enter the OTP.');
}
}
// Add event listeners for modals and buttons
window.onload = function() {
// Add event listener to forgot password link
const forgotPasswordLink = document.querySelector('.login-section p a');
if (forgotPasswordLink) {
forgotPasswordLink.addEventListener('click', openForgotPassword);
}
// Add event listeners to modal close buttons
const closeButtons = document.querySelectorAll('.close');
closeButtons.forEach(button => {
button.addEventListener('click', function() {
document.querySelectorAll('.modal').forEach(modal => {
modal.style.display = 'none';
});
});
});
// Add event listener to send OTP button
document.getElementById('sendOTPButton').addEventListener('click', sendOTP);
// Add event listener to verify OTP button
document.getElementById('verifyOTPButton').addEventListener('click', verifyOTP);
};