jquery to determine password strength verification code _jquery

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.