api-ix commited on
Commit
a685c13
·
verified ·
1 Parent(s): 06f32f1

Update signup.html

Browse files
Files changed (1) hide show
  1. signup.html +157 -25
signup.html CHANGED
@@ -100,6 +100,11 @@
100
  text-align: left;
101
  }
102
 
 
 
 
 
 
103
  .input-group i.field-icon {
104
  position: absolute;
105
  top: 50%;
@@ -134,7 +139,6 @@
134
 
135
  .input-group input:focus + i.field-icon { color: #c4b5fd; }
136
 
137
- /* Error state styling */
138
  .input-group input.error {
139
  border: 1px solid #ef4444;
140
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
@@ -152,6 +156,53 @@
152
  }
153
  .toggle-password:hover { color: #fff; }
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  /* --- BUTTON --- */
156
  .login-btn {
157
  width: 100%;
@@ -238,7 +289,6 @@
238
  75% { transform: translateX(8px); }
239
  }
240
 
241
- /* Mobile Adjustments */
242
  @media (max-width: 480px) {
243
  .login-card { padding: 30px 20px; }
244
  .login-card h2 { font-size: 26px; }
@@ -264,18 +314,29 @@
264
  <i class="fa-solid fa-at field-icon"></i>
265
  </div>
266
 
267
- <div class="input-group">
268
  <input type="password" id="password" placeholder="Password" required>
269
  <i class="fa-solid fa-lock field-icon"></i>
270
  <i class="fa-regular fa-eye toggle-password" data-target="password"></i>
271
  </div>
 
 
 
 
 
 
 
272
 
273
- <div class="input-group">
274
  <input type="password" id="confirm_password" placeholder="Confirm Password" required>
275
  <i class="fa-solid fa-lock field-icon"></i>
276
  <i class="fa-regular fa-eye toggle-password" data-target="confirm_password"></i>
277
  </div>
278
 
 
 
 
 
279
  <button type="submit" class="login-btn" id="signupBtn">Sign Up</button>
280
  </form>
281
 
@@ -318,9 +379,8 @@
318
  });
319
  }
320
 
321
- // 2. PASSWORD TOGGLE (For both fields)
322
  const toggleBtns = document.querySelectorAll('.toggle-password');
323
-
324
  toggleBtns.forEach(btn => {
325
  btn.addEventListener('click', () => {
326
  const targetId = btn.getAttribute('data-target');
@@ -333,41 +393,113 @@
333
  });
334
  });
335
 
336
- // 3. FORM VALIDATION & SUBMIT
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  const form = document.getElementById('signupForm');
338
  const signupBtn = document.getElementById('signupBtn');
339
- const passInput = document.getElementById('password');
340
- const confirmInput = document.getElementById('confirm_password');
341
 
342
  form.addEventListener('submit', (e) => {
343
  e.preventDefault();
344
 
345
- // Clear previous error styles
346
- passInput.classList.remove('error');
347
  confirmInput.classList.remove('error');
348
 
349
- const password = passInput.value;
350
  const confirm = confirmInput.value;
351
 
352
- // Check if passwords match
353
  if (password !== confirm) {
354
- // Shake animation
355
  card.classList.add('shake');
356
-
357
- // Highlight inputs red
358
- passInput.classList.add('error');
359
  confirmInput.classList.add('error');
360
 
361
- // Change button text temporarily
362
- const originalText = signupBtn.innerText;
363
- signupBtn.innerText = "Passwords don't match";
364
- signupBtn.style.background = "linear-gradient(135deg, #ef4444, #b91c1c)";
365
-
366
  setTimeout(() => {
367
  card.classList.remove('shake');
368
- signupBtn.innerText = originalText;
369
- signupBtn.style.background = ""; // Reset to CSS default
370
- }, 1500);
371
  return;
372
  }
373
 
 
100
  text-align: left;
101
  }
102
 
103
+ /* Adjusted margin for password groups to fit feedback text */
104
+ .input-group.password-group {
105
+ margin-bottom: 5px;
106
+ }
107
+
108
  .input-group i.field-icon {
109
  position: absolute;
110
  top: 50%;
 
139
 
140
  .input-group input:focus + i.field-icon { color: #c4b5fd; }
141
 
 
142
  .input-group input.error {
143
  border: 1px solid #ef4444;
144
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
 
156
  }
157
  .toggle-password:hover { color: #fff; }
158
 
159
+ /* --- STRENGTH & MATCH INDICATORS --- */
160
+
161
+ /* Container for feedback text/bars */
162
+ .feedback-container {
163
+ height: 20px; /* Fixed height to prevent jumping */
164
+ margin-bottom: 10px;
165
+ padding: 0 20px;
166
+ display: flex;
167
+ align-items: center;
168
+ justify-content: flex-start;
169
+ }
170
+
171
+ /* The background bar for strength */
172
+ .strength-bar-bg {
173
+ width: 100%;
174
+ height: 4px;
175
+ background: rgba(255, 255, 255, 0.1);
176
+ border-radius: 10px;
177
+ overflow: hidden;
178
+ display: none; /* Hidden by default */
179
+ position: relative;
180
+ }
181
+
182
+ /* The moving color fill */
183
+ .strength-bar-fill {
184
+ height: 100%;
185
+ width: 0%;
186
+ border-radius: 10px;
187
+ transition: width 0.3s ease, background-color 0.3s ease;
188
+ }
189
+
190
+ /* Text feedback styling */
191
+ .feedback-text {
192
+ font-size: 12px;
193
+ font-weight: 500;
194
+ opacity: 0;
195
+ transition: opacity 0.3s;
196
+ margin-left: 5px;
197
+ }
198
+
199
+ /* Text Colors */
200
+ .text-weak { color: #ef4444; }
201
+ .text-medium { color: #f59e0b; }
202
+ .text-strong { color: #10b981; }
203
+ .text-match { color: #10b981; }
204
+ .text-mismatch { color: #ef4444; }
205
+
206
  /* --- BUTTON --- */
207
  .login-btn {
208
  width: 100%;
 
289
  75% { transform: translateX(8px); }
290
  }
291
 
 
292
  @media (max-width: 480px) {
293
  .login-card { padding: 30px 20px; }
294
  .login-card h2 { font-size: 26px; }
 
314
  <i class="fa-solid fa-at field-icon"></i>
315
  </div>
316
 
317
+ <div class="input-group password-group">
318
  <input type="password" id="password" placeholder="Password" required>
319
  <i class="fa-solid fa-lock field-icon"></i>
320
  <i class="fa-regular fa-eye toggle-password" data-target="password"></i>
321
  </div>
322
+
323
+ <div class="feedback-container">
324
+ <div class="strength-bar-bg" id="strengthBarBg">
325
+ <div class="strength-bar-fill" id="strengthFill"></div>
326
+ </div>
327
+ <span id="strengthText" class="feedback-text"></span>
328
+ </div>
329
 
330
+ <div class="input-group password-group">
331
  <input type="password" id="confirm_password" placeholder="Confirm Password" required>
332
  <i class="fa-solid fa-lock field-icon"></i>
333
  <i class="fa-regular fa-eye toggle-password" data-target="confirm_password"></i>
334
  </div>
335
 
336
+ <div class="feedback-container">
337
+ <span id="matchText" class="feedback-text"></span>
338
+ </div>
339
+
340
  <button type="submit" class="login-btn" id="signupBtn">Sign Up</button>
341
  </form>
342
 
 
379
  });
380
  }
381
 
382
+ // 2. PASSWORD TOGGLE
383
  const toggleBtns = document.querySelectorAll('.toggle-password');
 
384
  toggleBtns.forEach(btn => {
385
  btn.addEventListener('click', () => {
386
  const targetId = btn.getAttribute('data-target');
 
393
  });
394
  });
395
 
396
+ // 3. STRENGTH CHECKER & MATCH CHECKER
397
+ const passwordInput = document.getElementById('password');
398
+ const confirmInput = document.getElementById('confirm_password');
399
+
400
+ // Strength Elements
401
+ const strengthBarBg = document.getElementById('strengthBarBg');
402
+ const strengthFill = document.getElementById('strengthFill');
403
+ const strengthText = document.getElementById('strengthText');
404
+
405
+ // Match Elements
406
+ const matchText = document.getElementById('matchText');
407
+
408
+ // Logic to check strength
409
+ passwordInput.addEventListener('input', () => {
410
+ const val = passwordInput.value;
411
+
412
+ // Show bar if text exists
413
+ if(val.length > 0) {
414
+ strengthBarBg.style.display = 'block';
415
+ strengthText.style.opacity = '1';
416
+ } else {
417
+ strengthBarBg.style.display = 'none';
418
+ strengthText.style.opacity = '0';
419
+ return;
420
+ }
421
+
422
+ // Calculate Score
423
+ let score = 0;
424
+ if(val.length >= 8) score++; // Length check
425
+ if(/[0-9]/.test(val)) score++; // Number check
426
+ if(/[!@#$%^&*]/.test(val)) score++; // Symbol check
427
+ if(/[A-Z]/.test(val)) score++; // Uppercase check
428
+
429
+ // Update UI based on score
430
+ if(val.length < 6) {
431
+ strengthFill.style.width = '20%';
432
+ strengthFill.style.backgroundColor = '#ef4444'; // Red
433
+ strengthText.innerText = 'Too Short';
434
+ strengthText.className = 'feedback-text text-weak';
435
+ } else if(score < 2) {
436
+ strengthFill.style.width = '40%';
437
+ strengthFill.style.backgroundColor = '#ef4444'; // Red
438
+ strengthText.innerText = 'Weak';
439
+ strengthText.className = 'feedback-text text-weak';
440
+ } else if(score === 2) {
441
+ strengthFill.style.width = '70%';
442
+ strengthFill.style.backgroundColor = '#f59e0b'; // Orange/Yellow
443
+ strengthText.innerText = 'Medium';
444
+ strengthText.className = 'feedback-text text-medium';
445
+ } else {
446
+ strengthFill.style.width = '100%';
447
+ strengthFill.style.backgroundColor = '#10b981'; // Green
448
+ strengthText.innerText = 'Strong';
449
+ strengthText.className = 'feedback-text text-strong';
450
+ }
451
+
452
+ // Re-check match in case user changed main password
453
+ checkMatch();
454
+ });
455
+
456
+ // Logic to check match
457
+ confirmInput.addEventListener('input', checkMatch);
458
+
459
+ function checkMatch() {
460
+ const pass = passwordInput.value;
461
+ const conf = confirmInput.value;
462
+
463
+ if (conf.length === 0) {
464
+ matchText.style.opacity = '0';
465
+ return;
466
+ }
467
+
468
+ matchText.style.opacity = '1';
469
+
470
+ if (pass === conf) {
471
+ matchText.innerHTML = '<i class="fa-solid fa-check"></i> Passwords match';
472
+ matchText.className = 'feedback-text text-match';
473
+ confirmInput.classList.remove('error');
474
+ } else {
475
+ matchText.innerHTML = '<i class="fa-solid fa-xmark"></i> Do not match';
476
+ matchText.className = 'feedback-text text-mismatch';
477
+ }
478
+ }
479
+
480
+ // 4. FORM SUBMIT
481
  const form = document.getElementById('signupForm');
482
  const signupBtn = document.getElementById('signupBtn');
 
 
483
 
484
  form.addEventListener('submit', (e) => {
485
  e.preventDefault();
486
 
487
+ // Clear previous styles
488
+ passwordInput.classList.remove('error');
489
  confirmInput.classList.remove('error');
490
 
491
+ const password = passwordInput.value;
492
  const confirm = confirmInput.value;
493
 
494
+ // Final Validation Check
495
  if (password !== confirm) {
 
496
  card.classList.add('shake');
497
+ passwordInput.classList.add('error');
 
 
498
  confirmInput.classList.add('error');
499
 
 
 
 
 
 
500
  setTimeout(() => {
501
  card.classList.remove('shake');
502
+ }, 1000);
 
 
503
  return;
504
  }
505