-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforgot.html
More file actions
112 lines (98 loc) · 6.06 KB
/
forgot.html
File metadata and controls
112 lines (98 loc) · 6.06 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Forgot Password</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="./styles.css">
</head>
<body class="flex items-center justify-center min-h-screen bg-yellow-100">
<div class="form-container w-full max-w-3.2xl p-10 bg-white rounded-lg shadow-lg">
<h2 class="text-5xl font-bold mb-6 text-center text-yellow-800">Reset Password</h2>
<form id="forgotForm" class="space-y-4">
<div>
<label class="block text-yellow-700">Email *</label>
<input type="email" id="email" name="email" required class="w-full p-2 border border-yellow-300 rounded" placeholder="Enter your email">
</div>
<div class="relative">
<label class="block text-yellow-700">New Password *</label>
<input type="password" id="newPassword" name="newPassword" required class="w-full p-2 border border-yellow-300 bg-blue-100 rounded" placeholder="Enter new password">
<button type="button" id="toggleNewPassword" class="absolute inset-y-0 right-3 flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-yellow-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path id="newEyeIcon" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
<path id="newEyeOutline" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
</svg>
</button>
</div>
<div class="relative">
<label class="block text-yellow-700">Confirm New Password *</label>
<input type="password" id="confirmPassword" name="confirmPassword" required class="w-full p-2 border border-yellow-300 bg-blue-100 rounded" placeholder="Confirm new password">
<button type="button" id="toggleConfirmPassword" class="absolute inset-y-0 right-3 flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-yellow-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path id="confirmEyeIcon" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
<path id="confirmEyeOutline" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
</svg>
</button>
</div>
<button type="submit" class="w-full bg-yellow-600 text-white p-2 rounded hover:bg-yellow-700">Reset Password</button>
</form>
<p class="text-center mt-4 text-yellow-700">
Remembered? <a href="login.html" class="text-yellow-900 underline">Back to Login</a>
</p>
</div>
<script>
function validatePassword(password) {
const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&_])[A-Za-z\d@$!%*#?&_]{8,}$/;
return regex.test(password);
}
const newPasswordInput = document.getElementById('newPassword');
const toggleNewPassword = document.getElementById('toggleNewPassword');
const newEyeIcon = document.getElementById('newEyeIcon');
const newEyeOutline = document.getElementById('newEyeOutline');
let newPasswordVisible = false;
toggleNewPassword.addEventListener('click', function () {
newPasswordVisible = !newPasswordVisible;
newPasswordInput.type = newPasswordVisible ? 'text' : 'password';
if (newPasswordVisible) {
newEyeIcon.setAttribute("d", "M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.542-7a9.967 9.967 0 013.356-4.472m3.234-2.157A9.956 9.956 0 0112 5c4.477 0 8.268 2.943 9.542 7a9.962 9.962 0 01-1.357 2.572");
newEyeOutline.setAttribute("d", "M3 3l18 18");
} else {
newEyeIcon.setAttribute("d", "M15 12a3 3 0 11-6 0 3 3 0 016 0z");
newEyeOutline.setAttribute("d", "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z");
}
});
const confirmPasswordInput = document.getElementById('confirmPassword');
const toggleConfirmPassword = document.getElementById('toggleConfirmPassword');
const confirmEyeIcon = document.getElementById('confirmEyeIcon');
const confirmEyeOutline = document.getElementById('confirmEyeOutline');
let confirmPasswordVisible = false;
toggleConfirmPassword.addEventListener('click', function () {
confirmPasswordVisible = !confirmPasswordVisible;
confirmPasswordInput.type = confirmPasswordVisible ? 'text' : 'password';
if (confirmPasswordVisible) {
confirmEyeIcon.setAttribute("d", "M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.542-7a9.967 9.967 0 013.356-4.472m3.234-2.157A9.956 9.956 0 0112 5c4.477 0 8.268 2.943 9.542 7a9.962 9.962 0 01-1.357 2.572");
confirmEyeOutline.setAttribute("d", "M3 3l18 18");
} else {
confirmEyeIcon.setAttribute("d", "M15 12a3 3 0 11-6 0 3 3 0 016 0z");
confirmEyeOutline.setAttribute("d", "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z");
}
});
document.getElementById('forgotForm').addEventListener('submit', function(e) {
e.preventDefault();
const newPassword = newPasswordInput.value;
const confirmPassword = confirmPasswordInput.value;
if (!validatePassword(newPassword)) {
alert('Password must be at least 8 characters long and include an uppercase letter, a lowercase letter, a number, and a special character.');
return;
}
if (newPassword !== confirmPassword) {
alert('Passwords do not match. Please try again.');
return;
}
localStorage.setItem('userPassword', newPassword);
alert('Password reset successful! Please login.');
window.location.href = 'login.html';
});
</script>
</body>
</html>