Ajax Password Strength Verification code
<script type= "Text/javascript" src= "Jquery.js" ></script>
<script type=text/javascript src= "Jquery.pstrength-min.1.2.js" ></SCRIPT>
<script
Type=text/javascript>
$ (function () {
$ ('. Password '). Pstrength ();
});
</SCRIPT>
HTML code:
Copy Code
<input Class=password Type=password name=password>
Additional Jquery.pstrength-min.1.2.js plug-in source code:
Copy Code
(function (A) {a.extend (A.fn,{pstrength:function (B) {var b=a.extend ({verdects:["very weak", "weak", "General", "good", "good", "],colors:[" # F00 "," #c06 "," #f60 "," #3c0 "," #3f0 "],scores:[10,15,30,40],common:[" password "," Sex "," God "," 123456 "," 123 "," Liverpool "," Letmein "," qwerty "," monkey "],minchar:6},b); return This.each (function () {var c=a (this). attr (" id "); A (This). After (/* "<div class=" Pstrength-minchar "id=" "+c+" _minchar ">minimum number of characters is" +b.minchar+ "</div>" * *); A (This). After ("<div class=" Pstrength-info "id=" "+c+" _text "></div>"); A (This). After ("<div class=" Pstrength-bar "id=" "+c+" _bar "style=" border:1px solid; font-size:1px; height:5px; Width:0px;text-align:left; " ></div> "); A (this). KeyUp (function () {A.fn.runpassword (A (this). Val (), C,b)})},runpassword:function (d,f,c) {nperc= A.fn.checkpassword (d,c); var b= "#" +f+ "_bar"; var e= "#" +f+ "_text"; if (nperc==-200) {strcolor= "#f00"; strtext= "unsafe password!"; A (B). css ({width: "0%"})}else{if (nperc<0&&nperc>-199) {strcolor= "#ccc"; Strtext= "Password Too Short"; A (B). css ({width: "5%"})}else{if (Nperc<=c.scores[0]) {strcolor=c.colors[0];strtext=c.verdects[0]; A (B). css ({width: "10%"})}else{if (Nperc>c.scores[0]&&nperc<=c.scores[1]) {strcolor=c.colors[1]; STRTEXT=C.VERDECTS[1]; A (B). css ({width: "25%"})}else{if (Nperc>c.scores[1]&&nperc<=c.scores[2]) {strcolor=c.colors[2]; STRTEXT=C.VERDECTS[2]; A (B). css ({width: "50%"})}else{if (Nperc>c.scores[2]&&nperc<=c.scores[3]) {strcolor=c.colors[3]; STRTEXT=C.VERDECTS[3]; A (B). css ({width: "75%"})}else{strcolor=c.colors[4];strtext=c.verdects[4]; A (b). css ({width: "92%"})}}}}}}a (b). css ({backgroundcolor:strcolor}); A (E). HTML ("<span style= ' color:" +strcolor+ ";") > "+strtext+" </span> ")},checkpassword:function (c,b) {var f=0;var e=b.verdects[0];if (C.length<b.minchar ) {f= (F-100)}else{if (c.length>=b.minchar&&c.length<= (b.minchar+2)) {f= (f+6)}else{if (C.length>= ( b.minchar+3) &&c.length<= (b.minchar+4)) {f= (f+12)}else{if (c.length>= (b.minchar+5)) {F= (f+18)}}}}if (C.match (/[a-z]/)) {f= (f+1)}if (C.match (/[a-z]/)) {f= (f+5)}if (C.match (/d+/)) {f= (f+5)}if (C.match) (/(. *[ 0-9].*[0-9].*[0-9])) {f= (f+7)}if (C.match (/.[!,@,#,$,%,^,&,*,?, _,~]/)) {f= (f+5)}if (C.match (/(. *[!,@,#,$,%,^ , &,*,?, _,~].*[!,@,#,$,%,^,&,*,?,])) {f= (f+7)}if (C.match ([a-z].*[a-z]) | [A-z].*[a-z])) {f= (f+2)}if (C.match (/([a-za-z])/) &&c.match (/([0-9])/) {f= f+3)}if (c.match ].*[!,@,#,$,%,^,&,*,?, _,~]) | ([!,@,#,$,%,^,&,*,?, _,~].*[a-za-z0-9])) {f= (f+3)}for (var d=0;d<b.common.length;d++) {if (c.tolowercase () = =b.common[d]) {F=-200}}return F}}) (JQuery)