From 576be5d94d34a70335b86b475f57a11db1e182f7 Mon Sep 17 00:00:00 2001 From: Rojimijar1 Date: Fri, 12 Jun 2026 20:25:18 +0545 Subject: [PATCH] Add real-time password validation feedback on signup --- frontend/src/components/register/Register.jsx | 74 ++++++++++++++++++- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/register/Register.jsx b/frontend/src/components/register/Register.jsx index 648d0cb..794af69 100644 --- a/frontend/src/components/register/Register.jsx +++ b/frontend/src/components/register/Register.jsx @@ -171,6 +171,64 @@ function AlertBanner({ message, onClose }) { ); } +function PasswordChecklist({ password }) { + if (!password) return null; + + const checks = [ + { label: "At least 7 characters", valid: password.length >= 7 }, + { label: "One uppercase letter", valid: /[A-Z]/.test(password) }, + { label: "One number", valid: /[0-9]/.test(password) }, + { label: "One special character", valid: /[^A-Za-z0-9]/.test(password) }, + ]; + + const score = checks.filter((c) => c.valid).length; + const strengthLabels = ["Weak", "Weak", "Fair", "Strong", "Very strong"]; + const strengthColors = ["#ef4444", "#ef4444", "#f59e0b", "#22c55e", "#16a34a"]; + + return ( + +
+ {checks.map((c, idx) => ( +
+ {c.valid ? "✓" : "○"} + {c.label} +
+ ))} +
+
+
+ +
+

+ {strengthLabels[score]} +

+
+
+ ); +} + function Register() { const Navigate = useNavigate(); const [days, setdays] = useState([]); @@ -447,9 +505,19 @@ function Register() { )} -

- Minimum 7 characters. -

+ + {user_values.password.length > 0 ? ( + + ) : ( + + Minimum 7 characters. + + )} +