Password Strength Verification for beginner js Regular Expressions

Source: Internet
Author: User

[Plain]
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> passwordCheck </title>
<Script type = "text/javascript" src = "Js/jquery1.6.1.js"> </script>
<Script type = "text/javascript">
$ (Function (){
$ ('# Pwd'). keyup (function (){
Var val = $ (this). val ();
IsDigit (val );
});

Function isDigit (s ){
Var pattern_d =/^ \ d + $/; // All numbers
Var pattern_s =/^ [A-Za-z] + $ // All characters
Var pattern_w =/^ \ w + $/; // number or character
Var pattern_W =/^ \ W + $ // all non-numbers and non-characters
Var pattern_r =/^ \ w + \ W + [\ w \ W] * \ w + $ // string that begins with a letter or number
Var html = '';
Var x = 0;
Var y = 0;

Certificate ('your user'{.html (s );
If(pattern_W.exe c (s )){
Html + = 'non-numeric or non-character <br/> ';
X = 0;
Y = 0;
}
If(pattern_w.exe c (s )){
Html + = 'Number or character <br/> ';
Y = 1;
}
If(pattern_d.exe c (s )){
Html + = 'all numbers <br/> ';
X = 1;
Y = 0;
}
If(pattern_s.exe c (s )){
Html + = 'all characters <br/> ';
X = 2;
Y = 0;
}
If(pattern_r.exe c (s )){
Html + = 'string starting with a letter or number <br/> ';
X = 3;
Y = 2;
}
If (y = 0 & x = 0 ){
Html + = 'incorrect password format <br/> ';
}
If (x> 0 & y = 0 ){
Html + = 'low security level <br/> ';
}
If (x = 0 & y = 1 ){
Html + = 'security level Medium <br/> ';
}
If (y = 2 ){
Html + = 'high security level <br/> ';
}
Html + = x + '<br/>' + y;
Certificate ('{password'{.html (html );
};
});
</Script>
</Head>
 
<Body>
<Form action = "#" method = "#">
Username: <input type = "text" name = ""/> <span id = "user"> </span> <br/>
Password: <input type = "password" name = "" id = "pwd"/> <span id = "password"> </span> <br/>
</Form>
</Body>
</Html>

Leave a message to share your thoughts.

When the password is a pure number or a pure letter, the security level is the lowest.

When the password is a combination of numbers and letters, the security level is medium.

The security level is high when the password contains numbers and letters and special characters.


When the password is a special symbol, spaces are not excluded.

When a special symbol exists, the special symbol cannot start or end with it.
 

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.