This article describes the jquery password strength verification code, shared for everyone to reference. Specifically as follows:
The desired effect screenshot is as follows:
JS Code:
$ (' #pass '). KeyUp (function (e) {
var strongregex = new RegExp ("^"? =.{ 8,}) (? =.*[a-z]) (? =.*[a-z]) (? =.*[0-9]) (? =.*\\w). *$ "," G ");
var Mediumregex = new RegExp ("^ (? =.{ 7,}) ((? =.*[a-z]) (? =.*[a-z]) | ( (? =.*[a-z]) (? =.*[0-9]) | ((? =.*[a-z]) (? =.*[0-9])). *$ "," G ");
var Enoughregex = new RegExp (? =.{ 6,}). * "," G ");
if (false = = Enoughregex.test ($ (this). Val ()) {
$ (' #passstrength '). html (' more Characters ');
} else if ( Strongregex.test ($ (this). Val ())) {
$ (' #passstrength '). ClassName = ' OK ';
$ (' #passstrength '). html (' strong! ');
else if (Mediumregex.test (). Val ()) {
$ (' #passstrength '). ClassName = ' alert ';
$ (' #passstrength '). html (' medium! ');
else {
$ (' #passstrength '). ClassName = ' ERROR ';
$ (' #passstrength '). html (' weak! ');
return true;
});
Page:
<input type= "password" name= "pass" id= "pass"/> <span "id="
></span>
The above is the jquery password strength Verification code, we can apply to their own projects, I hope you like.