Password Strength Meter jQuery Plugin

Category: Text & Input | March 26, 2020
Author: Òscar Casajuana
Official Page: Go to Website
Last Update: March 26, 2020
License: MIT

This lightweight jQuery plugin bind a progress bar that displays the strength meter of the entered password. It comes with multiple configuration options to create strength meter with custom error short, bad, good, and strong message. Likewise, you can also trigger custom events on different password lengths.

You can set the minimum length of the password and link the password input with other input fields. Moreover, this plugin also supports language translation for error messages. Similarly, you can also control the strength meter progress bar animation on input focus/blur.

You just need to include the plugin file into your project, then this plugin will start password strength visualization after initialization. So, you can install the plugin package by the following NPM or Bower commands.

NPM & Bower Installation

You can use the following NPM & Bower commands to install the “password-strength-meter” jQuery plugin.

$ npm install password-strength-meter

# Bower
$ bower install password-strength-meter

How to Create a Password Strength Meter

In order to create a password strength meter, we need to getting started with jQuery JavaScript library and Bootstrap CSS (optional). So, load the jQuery by adding the CDN link inside the head tag of your HTML page.

<!-- Bootstrap 3 CSS (optional for styles only) -->
<link type="text/css" rel="stylesheet" href="" />
<!-- jQuery JS -->
<script src=""></script>

After that, create an HTML form element and define username, and password field with the following mentioned classes.

<form action="#"> 
                <legend>Linked to username input (password cannot contain field text)</legend>
                <div class="form-group">
                    <label for="username">
                    <input id="username" type="text" placeholder="John Doe" class="form-control" />
                <div class="form-group">
                    <label for="linked">
                    <input id="linked" type="password" class="form-control" />

Finally, initialize the password plugin in the jQuery document ready function with the following configurations.

            field: '#username',
            showPercent: true

Advanced Configuration Options

If you want to create an advanced password strength you can set the custom values for these plugin options. So, the following are some advanced configuration options to create/customize password strength meter.

Option Default Type Description
showPercent true Boolean Decide whether to display password strength in percentages.


	showPercent : true,
showText true Boolean Enable/disable text message with strength progress bar.


	showText : true,
closestSelector “div” String It defines the closes selector.


	closestSelector : "div",
animate true Boolean This option enables/disable animation for the strength progress bar.


	animate : true,
field false Boolean Decide whether to select matched filed.


	field : false,
minimumLength 4 Number Defines the minimum required length for a password.


	minimumLength : 4,

Custom Events

If you want to execute a custom function on different password length, you can use the JavaScript if condition just like below:

$('#events').password().on('password.score',function (e, score) {
  if (score > 75) {
  }else {

Similarly, you can run a custom function on text change.

$('#events').on('password.text', (e, text, score) => {
  console.log('Called every time the text is changed')
  console.log('Current message is %s with a score of %d', text, score)

That’s all! I hope you find this tutorial helpful and able to create the password strength meter. If you need further help, you can ask your question by comment below. Thanks!

You Might Be Interested In:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.