1

I am looking for a very simple password strength script.

Something along the lines of

$('input[type=password]').pstrength({
   min-length: 5,
   callback: function(value){
      //you can do whatever you want with the value here
   }
});

So I don't want a progress bar, or anything visual at all.

Is there anything out there like this?

Hailwood
  • 89,623
  • 107
  • 270
  • 423

2 Answers2

1

try

var strength = 1;
var arr = [/{5,}/, /[a-z]+/, /[0-9]+/, /[A-Z]+/];
jQuery.each(arr, function(i, regexp) {
  if(this.value.match(regexp))
     strength++;
}

Read this article

jQuery password strength checker

Community
  • 1
  • 1
xkeshav
  • 53,360
  • 44
  • 177
  • 245
0

Strength of a password should be checked on behalf of several parameters like the presence of special characters and numbers, length of the password etc.

I have found the below tutorial with nice demo:

http://tinytute.com/2014/06/03/animated-password-strength-checker-quick-easy/

The jQuery code block:

    var passWord = $("#textBox").val();
    var passLength = passWord.length;
    var specialFlag = 0;
    var numberFlag = 0;
    var numberGenerator = 0;
    var total = 0;

    if(/^[a-zA-Z0-9- ]*$/.test(passWord) == false) {

        specialFlag =20;
    }


    if(passWord.match(/[0-9]/)) {

        numberFlag = 25;
    }

    if(passLength>4&&passLength<=6){
        numberGenerator =25;
    }else if(passLength>=7&&passLength<=9){
        numberGenerator =35;
    }else if(passLength>9){
        numberGenerator =55;
    }else if(passLength>0&&passLength<=4){
        numberGenerator =15;
    }else{
        numberGenerator =0;
    }

Hope these set of logic will solve the problem

Anjan
  • 1