password strength meter

This commit is contained in:
2026-04-06 15:48:27 -04:00
parent 8b74cab34e
commit b9ed00c127
5 changed files with 39 additions and 6 deletions

View File

@@ -87,3 +87,22 @@ changePasswordButton.addEventListener("click", () => {
displayError(err.message);
});
});
document.getElementById("new_password").addEventListener("input", () => {
score = EvaluatePassword(document.getElementById("new_password").value).score;
strengh_label = document.getElementById("strengh-label");
password_progress = document.getElementById("password-progress");
password_progress.style.width = score + "%";
if (score <= 40) {
strengh_label.innerText = "Strength: Weak";
password_progress.style.backgroundColor = "var(--password-strength-weak)";
} else if (score > 40 && score <= 70) {
strengh_label.innerText = "Strength: Medium";
password_progress.style.backgroundColor = "var(--password-strength-medium)";
} else if (score > 40 && score >= 70) {
strengh_label.innerText = "Strength: Strong";
password_progress.style.backgroundColor = "var(--password-strength-strong)";
}
});

View File

@@ -43,9 +43,6 @@ function EvaluatePassword(password) {
}
}
if (!accepted && isLongEnough) {
errors.push("Password is too simple. Try adding more variety or length.");
}
return {
score: Math.min(score, 100),
errors: errors,