PHPackages                             kartik-v/strength-meter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. kartik-v/strength-meter

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

kartik-v/strength-meter
=======================

A dynamic strength meter for password input validation with various configurable options.

v1.1.4(8y ago)871.2M↓14%36[1 issues](https://github.com/kartik-v/strength-meter/issues)[1 PRs](https://github.com/kartik-v/strength-meter/pulls)3BSD-3-ClauseJavaScript

Since Oct 16Pushed 4y ago9 watchersCompare

[ Source](https://github.com/kartik-v/strength-meter)[ Packagist](https://packagist.org/packages/kartik-v/strength-meter)[ Docs](https://github.com/kartik-v/strength-meter)[ RSS](/packages/kartik-v-strength-meter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)DependenciesVersions (7)Used By (3)

 [ ![Krajee Logo](https://camo.githubusercontent.com/4addfbb3869c3fc7d79befea4f06d9cf3655a686fb503df0da1d725859cfdef9/687474703a2f2f6b617274696b2d762e6769746875622e696f2f626f6f7473747261702d66696c65696e7075742d73616d706c65732f73616d706c65732f6b72616a65652d6c6f676f2d622e706e67) ](http://plugins.krajee.com "Krajee Plugins")
 strength-meter ---

 [ ![Donate](https://camo.githubusercontent.com/4af77d425ca202e55ab3d711b438e238ded194735bc345a019ac060e03e26227/687474703a2f2f6b617274696b2d762e6769746875622e696f2f626f6f7473747261702d66696c65696e7075742d73616d706c65732f73616d706c65732f646f6e6174652e706e67) ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DTP3NZQ6G2AYU "Donate via Paypal")
======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#------------------------strength-meter--------------------)

A dynamic strength meter for password input validation with various configurable options. The strength scoring calculation is inspired from [password meter](http://passwordmeter.com) created by Jeff Todnem.

Features
--------

[](#features)

1. Convert any password input to an advanced password strength validation plugin. Will fallback to a normal password input for browsers not supporting JQuery or Javascript.
2. The plugin will offer ability to toggle password mask (show/hide password text) and display a dynamic strength meter as you type. Uses advanced strength calculation algorithm which can be customized by setting/overriding the default validation `rules`.
3. The plugin automatically converts an input with `type = password` to the strength validation plugin if you set its `class = strength`. All options to the password input can be passed as HTML5 `data` attributes.
4. Configurable templates to control the style and display of the entire plugin. The password input and the various components of the strength meter can be customized. The default template uses styling compatible with Bootstrap 3.x &amp; Bootstrap 4.x markup to display the password input, toggle, and strength meter.
5. Internationalization enabled to show messages in languages other than Englsh. At this stage translations are available for 4 languages (German, French, Italian, and Russian). The titles for verdicts and toggle mask can be configured.
6. Show and hide meter and/or toggle password mask
7. Reset plugin to the initial value when the form is reset.
8. Plugin events that traps the change, reset, and toggle of the input.
9. Plugin methods to refresh the input and strength with a custom value.
10. Plugin methods to return score and verdict.
11. Configurable strength verdicts classes and titles.

Demo
----

[](#demo)

View the [plugin documentation](http://plugins.krajee.com/strength-meter) and [plugin demos](http://plugins.krajee.com/strength-meter/demo) at Krajee JQuery plugins.

Latest Release
--------------

[](#latest-release)

> NOTE: The latest version of the plugin is v1.1.4. Refer the [CHANGE LOG](https://github.com/kartik-v/strength-meter/blob/master/CHANGE.md) for details.

Pre-requisites
--------------

[](#pre-requisites)

1. Latest [JQuery](http://jquery.com/)
2. Most modern browsers supporting CSS3 &amp; JQuery. For Internet Explorer, one must use IE versions 9 and above.
3. [Bootstrap 4.x](http://getbootstrap.com/) (or bootstrap 3.x) is supported by default for styling. But usage of this framework is optional. The plugin templates use the Bootstrap 3.x markup by default. So for the default markup to render correct, you would need Bootstrap 3.x CSS to view the styles properly. If you do not wish to use Bootstrap, you can easily override the templates with your markup and styles.

Installation
------------

[](#installation)

### Using Bower

[](#using-bower)

You can use the `bower` package manager to install. Run:

```
bower install strength-meter

```

### Using Composer

[](#using-composer)

You can use the `composer` package manager to install. Either run:

```
$ php composer.phar require kartik-v/strength-meter "dev-master"

```

or add:

```
"kartik-v/strength-meter": "dev-master"

```

to the `require` section of your composer.json file

### Manual Install

[](#manual-install)

You can also manually install the plugin easily to your project. Just download the source [ZIP](https://github.com/kartik-v/strength-meter/zipball/master) or [TAR ball](https://github.com/kartik-v/strength-meter/tarball/master) and extract the plugin assets (css and js folders) into your project.

Usage
-----

[](#usage)

Step 1: Load the following assets in your header.

```

```

If you noticed, you need to load the `jquery.min.js` and `bootstrap.min.css` in addition to the `star-strength.min.css` and `star-strength.min.js`.

*Note:* You can skip the `bootstrap.min.css` if you do not need Bootstrap 3.x styling. To use your own style, you need to setup the `inputTemplate`, `meterTemplate`, and `mainTemplate` options to match your CSS Styling needs.

In addition, you can load a locale specific script for your language specific translation. For example to load German translations:

```

```

Step 2: Initialize the plugin on your page. For example,

```
// initialize with defaults
$("#password-id").strength();

// with plugin options
$("#password-id").strength({showMeter: true, toggleMask: false});
```

The `#password-id` is the identifier for the password input (`type=password`) on your page.

Alternatively, you can directly call the plugin options by setting data attributes to your input field.

```

```

Documentation
-------------

[](#documentation)

### Plugin Options

[](#plugin-options)

The plugin supports these following options:

### language

[](#language)

*string* language configuration for the plugin to enable the plugin to display messages for your locale (you must set the ISO code for the language). This setting also allows you to have multiple language widgets on the same page. The locale JS file for the language code must be defined as mentioned in the translations section. The file must be loaded after `strength-meter.js`.

#### showMeter

[](#showmeter)

*boolean* whether the strength meter is to be displayed. Defaults to `true`.

#### showToggle

[](#showtoggle)

*boolean* whether to display the checkbox for toggling display of password text. Defaults to `true`.

#### inputTemplate

[](#inputtemplate)

*string* the template for displaying the password input field (when `toggleMask` is `true`). This defaults to:

```

    {input}
    {toggle}

```

The following special variables will be replaced in the template:

- `{input}` will be replaced with the password input
- `{toggle}` will be replaced with the toggle mask checkbox.

#### inputNoToggleTemplate

[](#inputnotoggletemplate)

*string* the template for displaying the password input field (when `toggleMask` is `false`). This defaults to:

```
{input}

```

The following special variables will be replaced in the template:

- `{input}` will be replaced with the password input.

#### meterTemplate

[](#metertemplate)

*string* the template for displaying the password strength meter. This defaults to:

```

    {scorebar}
    {score}

{verdict}

```

The following special variables will be replaced in the template:

- `{scorebar}` will be replaced with the strength score color bar.
- `{score}` will be replaced with the strength score in %.
- `{verdict}` will be replaced with the calculated strength verdict.

#### mainTemplate

[](#maintemplate)

*string* the template for displaying the overall widget/plugin. This defaults to:

```

        {input}
        {meter}

```

The following special variables will be replaced in the template:

- `{input}` will be replaced with the parsed output from the `inputTemplate`.
- `{meter}` will be replaced with the parsed output from the `meterTemplate`.

#### meterClass

[](#meterclass)

*string* the CSS class for displaying the meter. Defaults to `kv-meter`.

#### scoreBarClass

[](#scorebarclass)

*string* the CSS class for displaying the strength score color bar. Defaults to `kv-scorebar`.

#### scoreClass

[](#scoreclass)

*string* the CSS class for displaying the strength score. Defaults to `kv-score`.

#### verdictClass

[](#verdictclass)

*string* the CSS class for displaying the strength verdict. Defaults to `kv-verdict`.

#### containerClass

[](#containerclass)

*string* the CSS class for wrapping the whole widget. Defaults to `kv-password`.

#### inputClass

[](#inputclass)

*string* the CSS class for displaying the password input. Defaults to `form-control`.

#### toggleClass

[](#toggleclass)

*string* the CSS class for displaying the toggle mask checkbox. Defaults to `kv-toggle`.

#### toggleTitle

[](#toggletitle)

*string* the title to be displayed on hovering the toggle mask checkbox. Defaults to `Show/Hide Password`. If you load in a locale specific JS, this will be overridden with the language specific `toggleTitle`.

#### verdictTitles

[](#verdicttitles)

*array* the verdict titles corresponding to each strength verdict (0 to 6). If you load in a locale specific JS, this will be overridden with the language specific verdict. Defaults to

```
{
    0: 'Too Short',
    1: 'Very Weak',
    2: 'Weak',
    3: 'Good',
    4: 'Strong',
    5: 'Very Strong',
}

```

#### verdictClasses

[](#verdictclasses)

*array* the verdict CSS classes corresponding to each strength verdict (0 to 6). Defaults to

```
{
    0: 'label label-default',
    1: 'label label-danger',
    2: 'label label-warning',
    3: 'label label-info',
    4: 'label label-primary',
    5: 'label label-success',
}

```

#### rules

[](#rules)

*array* the strength validation rules. You normally do not need to change this, as this will impact the strength score algorithm. Defaults to:

```
{
    midChar: 2,
    consecAlphaUC: 2,
    consecAlphaLC: 2,
    consecNumber: 2,
    seqAlpha: 3,
    seqNumber: 3,
    seqSymbol: 3,
    length: 4,
    number: 4,
    symbol: 6
}

```

Each rule element corresponds to the following:

- `midChar`: The multiplication factor (addition) for middle numbers or symbols.
- `consecAlphaUC`: The multiplication factor (reduction) for consecutive upper case alphabets.
- `consecAlphaLC`: The multiplication factor (reduction) for consecutive lower case alphabets.
- `consecNumber`: The multiplication factor (reduction) for consecutive numbers.
- `seqAlpha`: The multiplication factor (reduction) for sequential alphabets (3+).
- `seqNumber`: The multiplication factor (reduction) for sequential numbers (3+).
- `seqSymbol`: The multiplication factor (reduction) for sequential symbols (3+).
- `length`: The multiplication factor (addition) for the count of characters.
- `number`: The multiplication factor (addition) for count of numbers in the input.
- `symbol`: The multiplication factor (addition) for count of symbols in the input.

### Plugin Events

[](#plugin-events)

The plugin supports these events:

#### strength.change

[](#strengthchange)

This event is triggered when the password input/strength is changed.

**Example:**

```
$('#input-id').on('strength.change', function(event) {
    console.log("strength.change");
});
```

#### strength.reset

[](#strengthreset)

This event is triggered when the password input/strength is reset to initial value.

**Example:**

```
$('#password-id').on('strength.reset', function(event) {
    console.log("strength.reset");
});
```

#### strength.toggle

[](#strengthtoggle)

This event is triggered on toggling the password toggle mask (i.e. when password is shown/hidden).

**Example:**

```
$('#password-id').on('strength.toggle', function(event) {
    console.log("strength.toggle");
});
```

### Plugin Methods

[](#plugin-methods)

The plugin supports these methods:

#### refresh

[](#refresh)

Refreshes the strength after changing the password input value via javascript.

```
$('#password-id').val(3);
$('#password-id').strength('refresh');
```

#### reset

[](#reset)

Reset the strength to the score based on the initial value of the password. For example after a form reset.

```
$('#password-id').strength('reset');
```

#### score

[](#score)

Return the current strength score:

```
alert($('#password-id').strength('score'));
```

#### verdict

[](#verdict)

Return the current strength verdict index:

```
alert($('#password-id').strength('verdict'));
```

License
-------

[](#license)

**strength-meter** is released under the BSD 3-Clause License. See the bundled `LICENSE.md` for details.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity55

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 81.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~238 days

Recently: every ~292 days

Total

6

Last Release

3040d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3592619?v=4)[Kartik Visweswaran](/maintainers/kartik-v)[@kartik-v](https://github.com/kartik-v)

---

Top Contributors

[![kartik-v](https://avatars.githubusercontent.com/u/3592619?v=4)](https://github.com/kartik-v "kartik-v (44 commits)")[![caiwp](https://avatars.githubusercontent.com/u/5799618?v=4)](https://github.com/caiwp "caiwp (2 commits)")[![freetuts](https://avatars.githubusercontent.com/u/7605140?v=4)](https://github.com/freetuts "freetuts (2 commits)")[![adrian-enspired](https://avatars.githubusercontent.com/u/796525?v=4)](https://github.com/adrian-enspired "adrian-enspired (2 commits)")[![tibee](https://avatars.githubusercontent.com/u/3636947?v=4)](https://github.com/tibee "tibee (1 commits)")[![lars-t](https://avatars.githubusercontent.com/u/7504335?v=4)](https://github.com/lars-t "lars-t (1 commits)")[![metola](https://avatars.githubusercontent.com/u/8111455?v=4)](https://github.com/metola "metola (1 commits)")[![soullivaneuh](https://avatars.githubusercontent.com/u/1698357?v=4)](https://github.com/soullivaneuh "soullivaneuh (1 commits)")

---

Tags

passwordjquerybootstrapstrengthmeter

### Embed Badge

![Health badge](/badges/kartik-v-strength-meter/health.svg)

```
[![Health](https://phpackages.com/badges/kartik-v-strength-meter/health.svg)](https://phpackages.com/packages/kartik-v-strength-meter)
```

###  Alternatives

[nette/forms

📝 Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server &amp; client side validation and mature design.

54013.2M450](/packages/nette-forms)[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

791.2M17](/packages/kartik-v-yii2-password)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[rollerworks/password-strength-validator

Password-strength validator for Symfony

1455.7M6](/packages/rollerworks-password-strength-validator)[rollerworks/password-strength-bundle

Password-strength validator bundle for Symfony

1433.7M6](/packages/rollerworks-password-strength-bundle)[schuppo/password-strength

This package provides a validator for ensuring strong passwords in Laravel 4 applications.

1432.7M1](/packages/schuppo-password-strength)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
