Verify password strength on client [2], compatible with Firefox and IE

Source: Internet
Author: User

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>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.