Im currently working on a website that generates a random password. One part of it shows the safety of the current password. Until now i was only able to make the safety-indicator dependent on the current length of the password. I want to also include the current count of checked checkboxes in the safety indicator.
I tried this function to update the the count of checked checkboxes with "onchange":
function updateSafetyIndicator() {
const checks = document.querySelector(".checks");
const checkedCount = 0;
for (var i = 0; i < checks.length; i++) {
if (checks[i].checked) {
checkedCount++;
}
}
console.log(checkedCount)
if (checkedCount <= 1) {
passwordSafetyIndicator.id = "veryweak";
}
else if (checkedCount <= 2) {
passwordSafetyIndicator.id = "weak";
}
else if (checkedCount <= 3) {
passwordSafetyIndicator.id = "medium";
}
else if (checkedCount <= 4) {
passwordSafetyIndicator.id = "strong";
}
}
Aucun commentaire:
Enregistrer un commentaire