Check the strength of a password
The PasswordStrength plugin uses the popular zxcvbn library to estimate the strength of a password.
The following piece of code is the starting point to use it:
The sample code above assumes that the FormValidation files are placed inside the
vendors directory. You might need to change the path depending on where you place them on the server.
* presents a required parameter
| ||String||The field name|
| ||String||The default error message which will be shown to let user know that the password is weak. It then will be replaced with the warning message of zxcvbn library to indicate the specific reason why the password is weak|
| ||Number|| |
For a given password, the zxcvbn library will calculate its strength and the score can be one of 0, 1, 2, 3, 4. The password will be treated as invalid if the scroce if less than
The default value is 3
| ||Function|| |
The callback function that will be triggered after validating the password. The function takes three parameters:
By using this callback, we can display a progress bar based on the score to let user know how strong the password is.
You can click on the sample password below to see the result.
|Common password||Is valid?|
|Female names||Is valid?|
|Male names||Is valid?|
|English words on Wikipedia||Is valid?|
- v1.5.0: First release. It means that the PasswordStrength plugin requires FormValidation v1.5.0 or newer.