ASP.NET - Javascript for check password strength

Asked By Ravi Maurya on 05-May-11 01:21 PM
can any one give me script for checking password strength 

so that I can use it while registration 


thanks and regard 
Peter Bromberg replied to Ravi Maurya on 05-May-11 01:30 PM
Google is your friend. 

http://www.google.com/search?q=javascript+password+strength+algorithm

Riley K replied to Ravi Maurya on 05-May-11 08:31 PM
Use this function
 
   Call the below function CheckPassword() passing the password to be checked. The result is a string representing the password strength, from "Very Weak" to "Very Strong". You can show this text in a label and also block the form if the password strength is not strong or at least medium.
function CheckPassword(password)
  {
    var strength = new Array();
    strength[0] = "Blank";
    strength[1] = "Very Weak";
    strength[2] = "Weak";
    strength[3] = "Medium";
    strength[4] = "Strong";
    strength[5] = "Very Strong";
    
    var score = 1;
    
    if (password.length < 1)
      return strength[0];
    
    if (password.length < 4)
      return strength[1];
    
    if (password.length >= 8)
      score++;
    if (password.length >= 12)
      score++;
    if (password.match(/\d+/))
      score++;
    if (password.match(/[a-z]/) &&
      password.match(/[A-Z]/))
      score++;
    if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,£,(,)]/))
      score++;
    
    return strength[score];
  }


<div>
      Password:
      <input type="text" onchange="PasswordChanged(this)" />
      <span id="PasswordStrength"></span>
      <br />
      <input type="button" value="Check" onclick="return ButtonClicked()" />
    </div>

Hope this helps

For more info refer these links using jQuery

http://

http://
http://
Ravi S replied to Ravi Maurya on 05-May-11 10:11 PM
HI
try this

function passwordStrength(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("passwordDescription").innerHTML = desc[score];

         document
.getElementById("passwordStrength").className = "strength" + score;

}
<div>
<input type="password" name="pass" id="pass" onkeyup="passwordStrength(this.value)" />
</div>

refer the links..more example here
http://passwordadvisor.com/CodeAspNet.aspx
http://codeassembly.com/How-to-make-a-password-strength-meter-for-your-register-form/
Ravi S replied to Ravi Maurya on 05-May-11 10:13 PM
HI
try this

function passwordStrength(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("passwordDescription").innerHTML = desc[score];

         document
.getElementById("passwordStrength").className = "strength" + score;

}
<div>
<input type="password" name="pass" id="pass" onkeyup="passwordStrength(this.value)" />
</div>

refer the links..more example here
http://passwordadvisor.com/CodeAspNet.aspx
http://codeassembly.com/How-to-make-a-password-strength-meter-for-your-register-form/
usha replied to Ravi Maurya on 28-Jul-11 01:10 AM
my question is that even user enter the wrong password when he press submit button he got transfer on another page ,i want message should come to say please enter correct password