Giter Site home page Giter Site logo

pass-meter's Introduction

pass-meter

Build Status microjs npm

Simple password strength testing.

Optional Dependencies

  • jQuery 1.7 or higher (needed for plugin usage)

Install

npm install @syntaqx/pass-meter

Usage

When used as either a jQuery plugin or Module, Pass-Meter only expects a single argument. If the argument is a function, it is treated as the afterTest callback option. If you need to specify additional options, you will need to provide a standard options object.

jQuery

Simple call the $.passMeter plugin on any elements you'd like. Create your own styling in the callback:

$('input[type="password"]').passMeter(function (score) {
  alert('Your password is ' + score + '% strong.');
});

Or, with additional options:

$('input[type="password"]').passMeter({
  event: 'change',
  afterTest: function (score) {
    alert('Your password is ' + score + '% strong.');
  },
});

Module

var PassMeter = require('pass-meter');

var meter = new PassMeter();
var pass = 'apasswordtotest';

console.log('The password "' + pass + '" is ' + meter.test(pass) + '% strong');

Or, with additional options:

var PassMeter = require('pass-meter');

var meter = new PassMeter({
  afterTest: function (score, value) {
    console.log('The password ' + value + ' is ' + score + '% strong');
  },
});

meter.test('apasswordtotest');

Options

Variable Default Value Description
events keyup Events to bind when using the module as a jQuery plugin
afterTest null A callback for when a test has been completed.
commonPasswords ['password', '123456', '12345678', '1234', 'qwerty'] An array of common passwords to instantly fail.

License

This project is open source available under the MIT license.

pass-meter's People

Contributors

mbuehrig avatar syntaqx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pass-meter's Issues

Plugin Combination with ShowPassword

I'm combining your plugin with this one: https://github.com/wenzhixin/bootstrap-show-password
Everything works great except one particular thing. When I press to show the password, the password input is switched with a cloned text input with its value. For the life of me, I can't make your password meter read the value in that cloned text input. The funny thing is that when I hide the password back (and disable the text input showing only the password input), the password meter continues calculating the strength in the password type input. Can you give me a solution or a reason to why this is happening!?

I even set up a unique custom attribute to pass from the password input to the cloned text input, such as pass-strength="on" and then use:

`/* Password strength bar and dynamic color */
$('input[pass-strength="on"]').passMeter(function (score) {
$('.jquery-result-1 .progress-bar').width(score + '%');

if(score < 40) {
	$('.progress-bar').addClass('bg-danger');
}
else if(score > 40 && score <80) {
  	$('.progress-bar').addClass('bg-warning').removeClass('bg-danger');
}
else if(score > 80) {
  	$('.progress-bar').addClass('bg-success').removeClass('bg-warning');
}
});`

Create new releases for Bower

Hey, thank you for a nice little lib. Could you create a new release (v1.0.1) so that Bower detects it? If I bower install pass-meter it downloads 1.0.0 since that's the newest release.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.