Strong Password Tool

Language: Javascript

Skill Level:Beginner to Intermediate

Downloads: 580

Download File: Strong Password

Description of Strong Password:

Checking the user’s password strength is a good idea to ensure that they do not comprise themselves, or yourself. A standard “good” password will usually be at least 6 to 8 characters long and contain a combination of at least three of the following: lowercase and uppercase letters, numbers, and special characters. Password Strength provides you with the following tools to help.

  • Allows you to set a minimum acceptable password strength
  • Allows you to control the text of the password strength reply by passing html formatted text parameters.
  • Allows you to further control how the text appears by using CSS styles.
  • Uses jQuery to communicate with the HTML DOM
  • Requires very little knowledge of JavaScript.
  • Optionally allows you to check passwords against a dictionary.

Documentation:

Using Password Strength

  1. Add the script to your web page.
    Note: you may need to adjust the src attribute if you place your JavaScript files within a sub-directory.
    <script type="text/javascript" src=" strong_password.js"></script>
  2. Some time after your password fields have loaded, (you may do this after your page has loaded) you will need to create an instance of the Password Strength class.
    <script type="text/javascript">
    var sp = new StrongPassword({allowSpecialChars: true});
    </script>

Password Strength Methods

Constructor StrongPassword(). The constructor takes a associative array (Map) as a parameter to set certain values. Each value has a default listed below.

  • allowNumbers – Boolean (defaults to true). Should numbers be allowed to count more in the strength of the password?
  • allowSpecialChars – Boolean (defaults to false). Should special characters be allowed to count more in the strength of the password?
  • minAllowScore – the minimum score allowed for a password to be even acceptable. Defaults to 5.
  • minWeakScore – to even qualify for a weak password – use this value. Defaults to 10.
  • minIntermediateScore – minimum score to qualify for an intermediate password. Defaults to 15.
  • minStrongScore – minimum score to qualify for a strong password. Defaults to 22.
  • scoreTextNotAcceptable – if the password is not strong enough, use this text.
  • scoreTextWeak – if the password is of weak strength, use this text.
  • scoreTextIntermediate – if the password is of intermediate strength, use this text.
  • scoreTextStrong – if the password is strong, then display this text.
  • dictionaryLookupFile – if you want to look up a file to test your password against, then set this to the location. It will look it up with an AJAX call. The dictionary file should be passed a value to see what it is getting, and return a score modifier.
  • source – what is the source of the password field, for Password Strength to check. By default it is “password”. The id of the field needs to have this value.
  • realTimeCheck – should the password be checked and displayed at real time. Defaults to true.

getPasswordStrength() – returns the strength of the password. If you have a custom password strength display that you wish to use, you can use this method to determine the password’s strength.

Password Strength CSS Styles

  • .wdTooWeakPassword – CSS class for if the password is too weak to pass
  • .wdWeakPassword – CSS class for if the password is of weak strength
  • .wdIntermediatePassword – CSS class for if the password is of intermediate strength
  • .wdStrongPassword – CSS class for if the password is of strong strength
  • .wdStrengthHint – CSS class for the container of the password strength result. It is used regardless of the password strength, so it may be used to set default parameters.

Samples:

Simple Password Detector - also allows, with a press of a button, to get the strength of the password and display it in a text box.

Moving Scale - Watch as the Strong Password controls a sliding bar using only a single transparent image.

Showing Editable Text - Strong Password will also allow you to edit the text of your warning message.

Password Validation - using Form Validator (a free JavaScript validation tool) and a hidden field, it is possible to enforce a given password strength on form so your users don't use weak passwords.

Additional Downloads:

Please note that this tool requires jQuery 1.1.3 or greater to also be loaded from your page.

Image movement needs a 1x1 tranparent gif. You may use our blank.gif.