1. php page $ score = 0; if (! Empty ($ _ GET [& amp; 39; value & amp; 39;]) {received value $ str =$ _ GET [& amp; 39; value & amp; 39;] ;}else {$ str = & amp; 39; & amp; 39 ;;}if (preg_match (& quot; 1. php page $ score = 0; if (! Empty ($ _ GET ['value']) {// received value $ str = $ _ GET ['value'];} else {$ str = '';} if (preg_match ("/[0-9] +/", $ str) {$ score ++ ;} if (preg_match ("/[0-9] {3,}/", $ str) {$ score ++ ;} if (preg_match ("/[a-z] +/", $ str) {$ score ++ ;} if (preg_match ("/[a-z] {3,}/", $ str) {$ score ++ ;} if (preg_match ("/[A-Z] +/", $ str) {$ score + +;} if (preg_match ("/[A-Z] {3 ,}/", $ str) {$ score ++;} if (preg_match ("/[_ | \-| + | = | * |! | @ | # | $ | % | ^ | & | (|)] +/", $ Str) {$ score + = 2 ;} if (preg_match ("/[_ | \-| + | = | * |! | @ | # | $ | % | ^ | & | (|)] {3,}/", $ str) {$ score ++ ;} if (strlen ($ str) >=10) {$ score ++;} echo $ score; exit; 2. html page
Enter the password: |
|
Password strength: |
Weak |
Moderate |
Strong |
Excellent |
III. js script function getPassword () {var value = $ ("input [name = 'newpwd']"). attr ('value'); $. get ('index. php? R = account/testpwd ', {value: value}, function (data) {if (data >=1 & data <= 3) {$ (' # idsm1 '). attr ('class', 'pwdchkcon1'); // weak $ ('# idsm2 '). attr ('class', 'pwdchkcon0'); $ ('# idsm3 '). attr ('class', 'pwdchkcon0'); $ ('# idsm4 '). attr ('class', 'pwdchkcon0'); $ ('# idSMT1 '). show (); $ ('# idSMT0 '). hide (); $ ('# idSMT2 '). hide (); $ ('# idSMT3 '). hide (); $ ('# idSMT4 '). hide ();} else if (data >=4 & data <= 6) {// Medium $ ('# idsm1 '). attr ('class', 'pwdchkcon2'); $ ('# idsm2 '). attr ('class', 'pwdchkcon2'); $ ('# idsm3 '). attr ('class', 'pwdchkcon0'); $ ('# idsm4 '). attr ('class', 'pwdchkcon0'); $ ('# idSMT0 '). hide (); $ ('# idSMT1 '). hide (); $ ('# idSMT2 '). show (); $ ('# idSMT3 '). hide (); $ ('# idSMT4 '). hide ();} else if (data >=7 & data <= 8) {// strong $ ('# idsm1 '). attr ('class', 'pwdchkcon3'); $ ('# idsm2 '). attr ('class', 'pwdchkcon3'); $ ('# idsm3 '). attr ('class', 'pwdchkcon3'); $ ('# idsm4 '). attr ('class', 'pwdchkcon0'); $ ('# idSMT0 '). hide (); $ ('# idSMT1 '). hide (); $ ('# idSMT2 '). hide (); $ ('# idSMT3 '). show (); $ ('# idSMT4 '). hide ();} else if (data >=9 & data <= 10) {// excellent $ ('# idsm1 '). attr ('class', 'pwdchkcon4'); $ ('# idsm2 '). attr ('class', 'pwdchkcon4'); $ ('# idsm3 '). attr ('class', 'pwdchkcon4'); $ ('# idsm4 '). attr ('class', 'pwdchkcon4'); $ ('# idSMT0 '). hide (); $ ('# idSMT1 '). hide (); $ ('# idSMT2 '). hide (); $ ('# idSMT3 '). hide (); $ ('# idSMT4 '). show () ;}}) ;}4. css