0

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

enter image description here

enter image description here

enter image description here

Here is a link to the code. It works on JFiddle but it doesn't work on my website!

code

Code in JFiddle link

1 Answers1

2

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("");
}
kind user
  • 40,029
  • 7
  • 67
  • 77
Jason Krs
  • 704
  • 2
  • 9
  • 30
  • You welcome. Go though http://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons to undertand the difference between === and == – Jason Krs Jan 02 '17 at 22:34