-
Notifications
You must be signed in to change notification settings - Fork 110
/
signup.html
338 lines (286 loc) · 10.8 KB
/
signup.html
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Signup Form</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.signup-container {
background-color: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
max-width: 400px;
width: 100%;
}
.signup-container h2 {
text-align: center;
color: #4CAF50;
margin-bottom: 20px;
font-size: 24px;
}
.signup-container input {
width: 100%;
padding: 12px;
margin: 10px 0;
font-size: 16px;
border: 1px solid #ddd;
border-radius: 5px;
box-sizing: border-box;
transition: border-color 0.3s ease;
}
.signup-container input:focus {
border-color: #4CAF50;
}
.signup-container button {
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
font-size: 16px;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.signup-container button:hover {
background-color: #45a049;
}
.signup-container .error-message {
color: red;
font-size: 14px;
margin-top: -10px;
margin-bottom: 10px;
}
.signup-container .success-message {
color: green;
font-size: 14px;
margin-top: -10px;
margin-bottom: 10px;
}
.password-strength {
margin-top: 10px;
}
.password-strength .strength-bar {
height: 5px;
background-color: #ddd;
border-radius: 5px;
transition: width 0.3s ease;
}
.password-strength .strength-message {
font-size: 14px;
margin-top: 5px;
}
/* Responsive */
@media (max-width: 768px) {
.signup-container {
padding: 20px;
}
.signup-container h2 {
font-size: 20px;
}
.signup-container input {
padding: 10px;
}
.signup-container button {
padding: 10px;
font-size: 14px;
}
}
.circle {
height: 24px;
width: 24px;
border-radius: 50%;
position: fixed;
background-color: black; /* Default color of circles */
pointer-events: none; /* Prevent interaction with circles */
z-index: 9999;
transition: transform 0.1s ease-out;
}
</style>
</head>
<body>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<script>
// Store the mouse coordinates
const coords = { x: 0, y: 0 };
// Select all circles (you can add more circles to HTML as needed)
const circles = document.querySelectorAll(".circle");
// Customize the colors for the circles (optional)
const colors = ["#ffb56b", "#fdaf69", "#f89d63", "#f59761", "#ef865e", "#ec805d", "#e36e5c", "#df685c", "#d5585c", "#d1525c", "#c5415d", "#c03b5d", "#b22c5e", "#ac265e", "#9c155f", "#950f5f", "#830060", "#7c0060", "#680060", "#60005f", "#48005f", "#3d005e"];
// Initialize circle positions
circles.forEach((circle, index) => {
circle.x = 0;
circle.y = 0;
circle.style.backgroundColor = colors[index % colors.length]; // Assign colors
});
// Update mouse coordinates on move
window.addEventListener("mousemove", (e) => {
coords.x = e.clientX;
coords.y = e.clientY;
});
// Animation loop for circles
function animateCircles() {
let x = coords.x;
let y = coords.y;
circles.forEach((circle, index) => {
circle.style.left = `${x - 12}px`; // Offset for center alignment
circle.style.top = `${y - 12}px`;
circle.style.transform = `scale(${(circles.length - index) / circles.length})`; // Shrink effect
circle.x = x;
circle.y = y;
const nextCircle = circles[index + 1] || circles[0];
x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.3;
});
requestAnimationFrame(animateCircles);
}
// Start animation
animateCircles();
</script>
<div class="signup-container">
<h2>Signup</h2>
<form id="signupForm">
<input type="text" id="username" name="username" placeholder="Username" required>
<div id="usernameError" class="error-message"></div>
<input type="email" id="email" name="email" placeholder="Email" required>
<div id="emailError" class="error-message"></div>
<input type="password" id="password" name="password" placeholder="Password" required>
<div id="passwordError" class="error-message"></div>
<div class="password-strength">
<div id="strengthBar" class="strength-bar"></div>
<div id="strengthMessage" class="strength-message"></div>
</div>
<input type="password" id="confirmPassword" name="confirmPassword" placeholder="Confirm Password" required>
<div id="confirmPasswordError" class="error-message"></div>
<button type="submit">Sign Up</button>
<div id="successMessage" class="success-message"></div>
</form>
<div class="login-link">
<p>Already have an account? <a href="login.html">Login here</a></p>
</div>
</div>
<script>
const form = document.getElementById('signupForm');
const usernameInput = document.getElementById('username');
const emailInput = document.getElementById('email');
const passwordInput = document.getElementById('password');
const confirmPasswordInput = document.getElementById('confirmPassword');
const usernameError = document.getElementById('usernameError');
const emailError = document.getElementById('emailError');
const passwordError = document.getElementById('passwordError');
const confirmPasswordError = document.getElementById('confirmPasswordError');
const successMessage = document.getElementById('successMessage');
const strengthBar = document.getElementById('strengthBar');
const strengthMessage = document.getElementById('strengthMessage');
const updateStrengthMeter = (password) => {
let strength = 0;
if (password.length >= 8) strength++;
if (/[A-Z]/.test(password)) strength++;
if (/[a-z]/.test(password)) strength++;
if (/\d/.test(password)) strength++;
if (/[!@#$%^&*(),.?":{}|<>]/.test(password)) strength++;
// Update the strength bar
strengthBar.style.width = (strength * 20) + '%';
if (strength === 0) {
strengthBar.style.backgroundColor = '#ddd';
strengthMessage.textContent = '';
} else if (strength <= 2) {
strengthBar.style.backgroundColor = 'red';
strengthMessage.textContent = 'Weak password. Try adding numbers, symbols, and uppercase letters.';
} else if (strength <= 4) {
strengthBar.style.backgroundColor = 'orange';
strengthMessage.textContent = 'Moderate password. Add more complexity for a stronger password.';
} else {
strengthBar.style.backgroundColor = 'green';
strengthMessage.textContent = 'Strong password.';
}
};
passwordInput.addEventListener('input', (e) => {
const password = e.target.value;
updateStrengthMeter(password);
});
// Real-time email validation when user finishes typing
emailInput.addEventListener('blur', () => {
const emailPattern = /^[^\s@]+@[^\s@]+\.[a-zA-Z]{2,}$/;
if (!emailPattern.test(emailInput.value)) {
emailError.textContent = 'Please enter a valid email address.';
} else {
emailError.textContent = '';
}
});
form.addEventListener('submit', (e) => {
e.preventDefault();
let valid = true;
// Clear previous error messages
usernameError.textContent = '';
emailError.textContent = '';
passwordError.textContent = '';
confirmPasswordError.textContent = '';
successMessage.textContent = '';
// Username validation
if (usernameInput.value.length < 3) {
usernameError.textContent = 'Username must be at least 3 characters long.';
valid = false;
}
// Email validation
const emailPattern = /^[^\s@]+@[^\s@]+\.[a-zA-Z]{2,}$/;
if (!emailPattern.test(emailInput.value)) {
emailError.textContent = 'Please enter a valid email address.';
valid = false;
}
// Password validation
if (passwordInput.value.length < 8) {
passwordError.textContent = 'Password must be at least 8 characters long.';
valid = false;
}
// Confirm password validation
if (passwordInput.value !== confirmPasswordInput.value) {
confirmPasswordError.textContent = 'Passwords do not match.';
valid = false;
}
// If the form is valid, show success message and redirect
if (valid) {
successMessage.textContent = 'Signup successful!';
form.reset();
setTimeout(() => {
window.location.href = 'index.html';
}, 1000);
}
});
</script>
</body>
</html>