The basic idea before developing the script is to allow the user to evaluate the strength of the password which he is entering at the time of registration.
About the Code
if' checks whether or not the password length is greater than 4, if yes then 1 point value will be incremented by 1.These points will decide the CSS class to show as password strength graphically.
if' checks whether password contains lowercase and uppercase characters or not.
if' checks whether password contains at least 1 number or not.
if' checks whether password contains at least 1 special character or not.
if' checks whether password length is greater than 12 or not.
var points = 0;
if (password.length > 4) points++;
if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) points++;
if (password.match(/\d+/)) points++;
if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) points++;
if (password.length > 12) points++;
How the Code Works
Every time a user enters a character in the textbox, an
password_strength div will display colors according to the changed value of points variable.
password_description divwill show the text description of password using description (desc) array and points value.
Guidelines for Strong Passwords
Common guidelines for choosing good passwords are designed to make passwords less easily discovered by intelligent guessing:
- Include numbers, symbols, upper and lowercase letters in passwords.
- Password length should be around 12 to 14 characters.
- Avoid passwords based on repetition, dictionary words, letter or number sequences, usernames, or biographical information like names or dates.
- 7th August, 2008: Initial post