Previously sent a about using JavaScript to verify the strength of the password, the program is very concise, only a regular will be able to verify all the circumstances, but because the use of the method of trickery, so only in IE use, in the FF failure, now modify to do a compatible version.
The rules are as follows (four grades, higher levels of ultra-high strength):
0. The password is blank.
1. Password length is less than six digits. Or a combination of passwords.
2. Password length is greater than five bits, and there are two combinations.
3. The password length is greater than five digits, and has three kinds of combinations.
4. Password length is greater than five digits, and there are four combinations.
Four combinations of exponential words, lowercase letters, uppercase letters, other characters
The source code is as follows:
The following are the referenced contents: function Evaluatepassword (Word) { if (Word = = "") { return 0; } else if (Word.length < 6) { return 1; } Else { Return Word.match (/[a-z] (?!) [^a-z]*[a-z]) | [A-z] (?! [^a-z]*[a-z]) |\d (?! [^\d]*\d) | [^a-za-z\d] (?! [a-za-z\d]*[^a-za-z\d])/g). length; } } |
Test code:
<script language= JavaScript Function Evaluatepassword (word) { if (word = = ") { return 0; } Else if (Word.length < 6) { return 1; } Else { return Word.match (/[a-z] (?!) [^a-z]*[a-z]) | [A-z] (?! [^a-z]*[a-z]) |\d (?! [^\d]*\d) | [^a-za-z\d] (?! [a-za-z\d]*[^a-za-z\d])/g). length; } } var test = new Array ("", "a1_", "abcdef", "abcde123", "ads23%", "aa1b2^&2"); for (var i in test) { document.write (Test[i] + "has a password strength of + Evaluatepassword (test[i)) +" <br> ;"); } </script> |