1 2 3function RenderPasswordStrength(strengthBar, password) 4 { 5 var currentPwdStrength = 0; 6 if(PasswordHasMinimumLength(password)) 7 { 8 if(PasswordContainsUpperCase(password)) 9 { 10 currentPwdStrength++; 11 } 12 if(PasswordContainsLowerCase(password)) 13 { 14 currentPwdStrength++; 15 } 16 if(PasswordContainsDigit(password)) 17 { 18 currentPwdStrength++; 19 } 20 if(PasswordContainsSymbol(password)) 21 { 22 currentPwdStrength++; 23 } 24 if(PasswordHasPreferredLength(password)) 25 { 26 currentPwdStrength++; 27 } 28 } 29 30 var barItemColor="Red"; 31 var strongEnough = false; 32 switch(currentPwdStrength) 33 { 34 case 0: 35 case 1: 36 case 2: 37 barItemColor="Red"; 38 strongEnough = false; 39 break; 40 case 3: 41 barItemColor="Orange"; 42 strongEnough = true; 43 break; 44 case 4: 45 case 5: 46 barItemColor="Green"; 47 strongEnough = true; 48 break; 49 } 50 51 52 var strengthBarContent = "<div class=\"passwordStrengthBar\">"; 53 for(iBar=0; iBar<=currentPwdStrength; iBar++) 54 { 55 strengthBarContent += "<div class=\"passwordStrengthBarItem\" style=\"background-color: " + barItemColor + ";\"> </div>"; 56 } 57 58 strengthBarContent += "</div>"; 59 60 if(strongEnough) 61 { 62 strengthBarContent += "<img class=\"passwordStrengthIcon\" src=\"/App_Themes/Buckaroo/Images/Buttons/ok.png\" alt=\"Password complies with rules\" title=\"Password complies with rules\"/>"; 63 } 64 else 65 { 66 strengthBarContent += "<img class=\"passwordStrengthIcon\" src=\"/App_Themes/Buckaroo/Images/Buttons/not_ok.png\" alt=\"Password too weak\" title=\"Password too weak\"/>"; 67 } 68 69 strengthBar.html(strengthBarContent); 70 71 return strongEnough; 72 } 73 74 function PasswordContainsUpperCase(password) 75 { 76 var rexp = /[A-Z]/g; 77 if (rexp.test(password)) 78 { 79 return true; 80 } 81 return false; 82 } 83 function PasswordContainsLowerCase(password) 84 { 85 var rexp = /[a-z]/g; 86 if (rexp.test(password)) 87 { 88 return true; 89 } 90 return false; 91 } 92 function PasswordContainsDigit(password) 93 { 94 var rexp = /[0-9]/g; 95 if (rexp.test(password)) 96 { 97 return true; 98 } 99 return false; 100 } 101 function PasswordContainsSymbol(password) 102 { 103 var rexp = /\W/g; 104 if (rexp.test(password)) 105 { 106 return true; 107 } 108 return false; 109 } 110 function PasswordHasMinimumLength(password) 111 { 112 if(password.length>5) 113 { 114 return true; 115 } 116 return false; 117 } 118 function PasswordHasPreferredLength(password) 119 { 120 if(password.length>13) 121 { 122 return true; 123 } 124 return false; 125 }
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.