Check Password Strength with JavaScript and Regular Expressions:
This post is  good example of a Password Strength checker that uses JavaScript and Regular Expressions. It check the following conditions to create secure password.
  • The password must contains greater than 6 character
  • The password must have both lower and uppercase characters
  • The password must have at least one number
  • The password must have at least one special character

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <title>Dotnetcluster-Password strength checker</title>
<!-- -->
    <script language="javascript" type="text/javascript">
function pwdStrength(password)
        var desc = new Array();
        desc[0] = "Very Weak";
        desc[1] = "Weak";
        desc[2] = "Better";
        desc[3] = "Medium";
        desc[4] = "Strong";
        desc[5] = "Strongest";
        var score   = 0;
        //if password bigger than 6 give 1 point
        if (password.length > 6) score++;
        //if password has both lower and uppercase characters give 1 point      
        if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;
        //if password has at least one number give 1 point
        if (password.match(/\d+/)) score++;
        //if password has at least one special caracther give 1 point
        if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;
        //if password bigger than 12 give another 1 point
        if (password.length > 12) score++;
         document.getElementById("pwdDescription").innerHTML = desc[score];
         document.getElementById("pwdStrength").className = "strength" + score;
                    Password<input type="password" name="pass" id="pass" onkeyup="pwdStrength(this.value)" />
                <div id="pwdDescription" style="color: red"">
 Demo for check password strength:
That's all. If this post is useful for you , please share this to your friends. Thanks!


Related Posts Plugin for WordPress, Blogger...