elboletaire / password-strength-meter

:key: A password strength meter for jQuery
https://elboletaire.github.io/password-strength-meter/
GNU General Public License v3.0
107 stars 45 forks source link

manually trigger on password update #14

Closed melvinchia closed 5 years ago

melvinchia commented 6 years ago

Hi, I programatically update the password field using

$("#password_field").val("new_password");

but the score isn't updated. How do I manually trigger the scoring?

melvinchia commented 6 years ago

Found it.. You could probably add a method to do it programatically though..

$("#password_field").trigger("keyup").trigger("focus");

Documenting it in case anybody else needs to do it for now.

Edit: Added focus trigger. If the field was blank and not focused before the .val took effect, the focus trigger brings up the strength meter. Without the focus, the score is updated but the visuals aren't.

elboletaire commented 5 years ago

I don't see the need to add a method for something that you can do as you stated (using trigger).

BTW, I've updated your comments to properly use codeblocks :wink: