js-Password Complexity

Source: Internet
Author: User

<TITLE>FLYSO blog--Password Strength </title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<body>
User password:
<input type= "password" name= "pwd" onblur= "chkpwd (This)"/>
<div id= "Chkresult" ></div>
</body>


<script type= "Text/javascript" >
function Chkpwd (obj) {
var T=obj.value;
var id=getresult (t);

Define the corresponding message prompt
var msg=new Array (4);
msg[0]= "Password is too short. ";
msg[1]= "Password strength is poor. ";
msg[2]= "Password strength is good. ";
msg[3]= "Password strength is high. ";

var sty=new Array (4);
sty[0]=-45;
sty[1]=-30;
sty[2]=-15;
sty[3]=0;

var col=new Array (4);
Col[0]= "Gray";
col[1]= "Red";
Col[2]= "#ff6600";
Col[3]= "Green";

Set the display effect
var bimg= "myfile/images/pwdpic1.gif";//a picture used for display
var swidth=300;
var sheight=15;
var Bobj=document.getelementbyid ("Chkresult");

Bobj.style.fontsize= "12px";
Bobj.style.color=col[id];
Bobj.style.width=swidth + "px";
Bobj.style.height=sheight + "px";
Bobj.style.lineheight=sheight + "px";
bobj.style.background= "url (" + bimg + ") No-repeat Left" + sty[id] + "px";
Bobj.style.textindent= "20px";
Bobj.innerhtml= "detection hint:" + msg[id];
}

Define detection functions, return 0/1/2/3 for invalid/poor/general/strong
function GetResult (s) {
if (S.length < 4) {
return 0;
}
var ls = 0;
if (S.match (/[a-z]/ig)) {
ls++;
}
if (S.match (/[0-9]/ig)) {
ls++;
}
if (S.match (/(. [ ^a-z0-9]) (/ig)) {
ls++;
}
if (S.length < 6 && ls > 0) {
ls--;
}
return LS
}
</script>

js-Password Complexity

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.