1. If the password is less than five characters, it is considered as a weak password.
2. If the password is composed of only one of the numbers, lower-case letters, upper-case letters, or other special characters, it is considered as a weak password.
3. If the password is composed of two types of characters: Numbers, lowercase letters, uppercase letters, or other special characters, the password is considered to be a moderately secure password.
4. If the password is composed of more than three types of characters: Numbers, lower-case letters, upper-case letters, or other special characters, it is considered a safe password.
Copy codeThe Code is as follows:
<Script language = "javascript">
// CharMode function CharMode (iN ){
If (iN> = 48 & iN <= 57) // number
Return 1;
If (iN> = 65 & iN <= 90) // uppercase letter
Return 2;
If (iN> = 97 & iN <= 122) // lower case
Return 4;
Else
Return 8; // special character // bitTotal function bitTotal (num ){
Modes = 0;
For (I = 0; I <4; I ++ ){
If (num & 1) modes ++;
Num >>> = 1; return modes; // function checkStrong (sPW ){
If (sPW. length <= 4)
Return 0; // The password is too short
Modes = 0;
For (I = 0; I <sPW. length; I ++) {Modes | = CharMode (sPW. charCodeAt (I); return bitTotal (Modes); // pwStrength function pwStrength (pwd ){
O_color = "# eeeeee ";
Rochelle color = "# FF0000 ";
M_color = "# FF9900 ";
H_color = "#33CC00 ";
If (pwd = null | pwd = ''){
Lcolor = Mcolor = Hcolor = O_color; else {
S_level = checkStrong (pwd );
Switch (S_level ){
Case 0:
Lcolor = Mcolor = Hcolor = O_color;
Case 1:
Lcolor = L_color;
Mcolor = Hcolor = O_color;
Break;
Case 2:
Lcolor = Mcolor = M_color;
Hcolor = O_color;
Break;
Default:
Lcolor = Mcolor = Hcolor = H_color ;}
Document. getElementByIdx_x ("strength_L"). style. background = Lcolor;
Document. getElementByIdx_x ("strength_M"). style. background = Mcolor;
Document. getElementByIdx_x ("strength_H"). style. background = Hcolor;
Return; </script>
<Form name = form1 action = "">
Enter the password: <input type = "password" size = "10" onKeyUp = "pwStrength (this. value)" onBlur = "pwStrength (this. value)">
<Br> password strength:
<Table width = "217" border = "1" cellspacing = "0" cellpadding = "1"
Bordercolor = "# cccccc" height = "23" style = 'display: inline'>
<Tr align = "center" bgcolor = "# eeeeee">
<Td width = "33%" id = "strength_L"> weak </td>
<Td width = "33%" id = "strength_M"> medium </td>
<Td width = "33%" id = "strength_H"> strong </td>
</Tr>
</Table>
</Form>