-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.html
More file actions
97 lines (88 loc) · 4.37 KB
/
signup.html
File metadata and controls
97 lines (88 loc) · 4.37 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Signup</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-blue-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-blue-800">Signup</h2>
<form id="signupForm" class="space-y-4">
<div>
<label class="block text-blue-700">Name *</label>
<input type="text" id="name" name="name" required class="w-full p-2 border border-blue-300 rounded">
</div>
<div>
<label class="block text-blue-700">Email *</label>
<input type="email" id="email" name="email" required class="w-full p-2 border border-blue-300 rounded">
</div>
<div class="relative mt-4">
<label class="block text-blue-700">Password *</label>
<div class="relative">
<input type="password" id="password" name="password" required class="w-full p-3 pr-12 border border-blue-300 rounded" />
<button type="button" id="togglePassword" class="absolute inset-y-0 right-3 flex items-center">
<!-- Only one blue eye icon -->
<svg xmlns="http://www.w3.org/2000/svg" id="eyeIcon" class="h-5 w-5 text-blue-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path id="eyePath" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
<path id="eyeOutline" 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>
<button type="submit" class="w-full bg-blue-600 text-white p-2 rounded hover:bg-blue-700">Signup</button>
</form>
<p class="text-center mt-4 text-blue-700">
Already have an account? <a href="login.html" class="text-blue-900 underline">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 passwordInput = document.getElementById('password');
const togglePassword = document.getElementById('togglePassword');
const eyeIcon = document.getElementById('eyeIcon');
const eyePath = document.getElementById('eyePath');
const eyeOutline = document.getElementById('eyeOutline');
let passwordVisible = false;
togglePassword.addEventListener('click', function () {
passwordVisible = !passwordVisible;
passwordInput.type = passwordVisible ? 'text' : 'password';
if (passwordVisible) {
// Eye off
eyeIcon.innerHTML = `
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.542-7
a9.967 9.967 0 013.356-4.472m3.234-2.157A9.956 9.956 0 0112 5
c4.477 0 8.268 2.943 9.542 7a9.962 9.962 0 01-1.357 2.572"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M3 3l18 18"/>
`;
} else {
// Eye normal
eyeIcon.innerHTML = `
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
<path 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"/>
`;
}
});
document.getElementById('signupForm').addEventListener('submit', function(e) {
e.preventDefault();
const password = passwordInput.value;
if (!validatePassword(password)) {
alert('Password must be at least 8 characters long and include an uppercase letter, a lowercase letter, a number, and a special character.');
return;
}
localStorage.setItem('userPassword', password);
alert('Signup successful! Redirecting to the login page.');
window.location.href = 'login.html';
});
</script>
</body>
</html>