Reputation:
I'm trying to write a password strength function. When a user types in a password it shows them whether their password is "weak","good", or "strong" using a meter and text.
However if a user typed a weak password and deleted their password in the input field then proceeds to type a strong password the meter will show as strong however the text stays as "weak" since that is the last password they typed before erasing their text. Here is my query. I have tried both .text and .html but they both give me the same results
Here is a link to the code. It works on JFiddle but it doesn't work on my website!
Code in JFiddle link
Upvotes: 0
Views: 354
Reputation: 714
I just tested your code. I think you forgot to add
$('#password-warning').text("")
in the last else if
.
By the way, instead of using ===
why don't you just use ==
. Don't forget ===
requires both operand to be of the same type. Try to replace your last else if
block with the following :
else if (password == ""){
$('#password-strength-meter').val(0);
$('#password-warning').text("");
}
Upvotes: 2