Js calls this function and returns the password strength level
Function getStrength (passwd) {intScore = 0; if (passwd. match (/[a-z]/) // [verify] at least one lowercase letter {intScore = (intScore + 1)} if (passwd. match (/[A-Z]/) // [validate] at least one uppercase letter {intScore = (intScore + 5)} // single verify if (passwd. match (// d +/) // [verify] at least one number {intScore = (intScore + 5)} if (passwd. match (/d. */d. */d)/) // [verify] at least three digits {intScore = (intScore + 5)} // verify if (passwd. match (/[!, @ # $ % ^ &*? _ ~] /) // [Verify] at least one special character {intScore = (intScore + 5)} if (passwd. match (/([!, @ # $ % ^ &*? _ ~]. *[!, @ # $ % ^ &*? _ ~]) /) // [Verify] at least two special characters {intScore = (intScore + 5)} // composite verify if (passwd. match (/[a-z]/) & passwd. match (/[A-Z]/) // [validate] contains both upper and lower case {intScore = (intScore + 2)} if (passwd. match (// d/) & passwd. match (// D/) // [verification] contains both letters and numbers {intScore = (intScore + 2)} // [verification] contains both uppercase and lowercase letters, number and special character if (passwd. match (/[a-z]/) & passwd. match (/[A-Z]/) & passwd. match (// d/) & passwd. match (/[!, @ # $ % ^ &*? _ ~] /) {IntScore = (intScore + 2)} return intScore;} function getStrength (passwd) {intScore = 0; if (passwd. match (/[a-z]/) // [verify] at least one lowercase letter {intScore = (intScore + 1)} if (passwd. match (/[A-Z]/) // [validate] at least one uppercase letter {intScore = (intScore + 5)} // single verify if (passwd. match (// d +/) // [verify] at least one number {intScore = (intScore + 5)} if (passwd. match (/d. */d. */d)/) // [verify] at least three digits {intScore = (intScore + 5)} // if (Passwd. match (/[!, @ # $ % ^ &*? _ ~] /) // [Verify] at least one special character {intScore = (intScore + 5)} if (passwd. match (/([!, @ # $ % ^ &*? _ ~]. *[!, @ # $ % ^ &*? _ ~]) /) // [Verify] at least two special characters {intScore = (intScore + 5)} // composite verify if (passwd. match (/[a-z]/) & passwd. match (/[A-Z]/) // [validate] contains both upper and lower case {intScore = (intScore + 2)} if (passwd. match (// d/) & passwd. match (// D/) // [verification] contains both letters and numbers {intScore = (intScore + 2)} // [verification] contains both uppercase and lowercase letters, number and special character if (passwd. match (/[a-z]/) & passwd. match (/[A-Z]/) & passwd. match (// d/) & passwd. match (/[!, @ # $ % ^ &*? _ ~] /) {IntScore = (intScore + 2)} return intScore;
} Another method. Use a regular expression to verify the password strength. The password consists of 6 digits or characters and must contain one digit and one character.
^ (? = \ D {0, 5} [a-zA-Z]) (? = [A-zA-Z] {} \ d) [a-zA-Z0-9] {6} $ ^ (? = \ D {0, 5} [a-zA-Z]) (? = [A-zA-Z] {} \ d) [a-zA-Z0-9] {6} $1. a ^ [a-zA-Z0-9] {6} $ match the entire password string
2. Next, an asserted that the verification password must contain characters (? = \ D {0, 5} [a-zA-Z])
3. Similar to step 1, it is also an asserted that the verification password must contain numbers (? = [A-zA-Z] {0, 5} \ d)