Password Strength

前2天访问hotmail的Sign Up(注册)页面,发现现在页面越做越好了,其中一个Password Strength功能让我记忆犹新,它可以衡量1个密码的健壮度,试了几次果然不错。今天晚上没什么好看的电视,The Simpons又是看过的,what a usual night!!!于是随手自己写了个Password Strength,和Hotmail Sign Up页面上的差不多,Pretty Easy。
只要打开个记事本把下面的源码粘帖进去,保存文件主名无所谓,只要扩展名为htm或者html。用IE打开它,就可以enjoy yourself了。对了,今天是New Year's Eve,祝大家Happy New Year&Good Luck To My Exams呵呵.

<!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>
<title>Password Strength</title>
</head>
<body>
<script language="javascript">

function IsLetter(c){
return (c>='a' && c<='z') || (c>='A') && (c<='Z');
}

function IsNumber(c){
return (c>=0 && c<=9);
}

function IsSymbol(c){
return !IsLetter(c) && !IsNumber(c);
}

function IsSpace(c){
return c==' ';
}

function pwdTxt_onkeyup() {
var i;
var l,n,s
l=0;
n=0;
s=0;
for(i=0;i<pwdTxt.value.length;i++){
var c=pwdTxt.value.charAt(i);
if (IsSpace(c)){
pwdTxt.value=pwdTxt.value.substring(0,pwdTxt.value.length-1);
return;
}
if (IsLetter(c))
l=1;
if(IsNumber(c))
n=1;
if (IsSymbol(c))
s=1;
}

if ((l+n+s)==0){
Weak.style.background="lightgrey";
Weak.style.color="silver";
Medium.style.background=Weak.style.background;
Medium.style.color="silver";
Powerful.style.background=Weak.style.background;
Powerful.style.color="silver";
}

if ((l+n+s)==1){
Weak.style.background="red";
Weak.style.color="black";
Medium.style.background="lightgrey";
Medium.style.color="lightgrey";
Powerful.style.background="lightgrey";
Powerful.style.color="lightgrey";
}

if ((l+n+s)==2){
Weak.style.background="yellow";
Weak.style.color="yellow";
Medium.style.background="yellow";
Medium.style.color="Black";
Powerful.style.background="lightgrey";
Powerful.style.color="lightgrey";
}

if ((l+n+s)==3){
Weak.style.background="green";
Weak.style.color="green";
Medium.style.background="green";
Medium.style.color="green";
Powerful.style.background="green";
Powerful.style.color="black";
}

}

</script>

<input style="border-right: silver 1px solid; border-top: silver 1px solid;
border-left: silver 1px solid; width: 313px; border-bottom: silver 1px solid"
type="password" name="pwdTxt" language="javascript" οnkeyup="return pwdTxt_onkeyup()" maxlength="15"/><br />
<br />
<table>
<tr>
<td style="border-right: gray 1px solid; border-top: gray 1px solid; border-left: gray 1px solid;
width: 100px; border-bottom: gray 1px solid; background-color: lightgrey; color: silver; text-align: left;" id="Weak">
<span style="font-size: 10pt; font-family: Tahoma">
Weak</span></td>
<td style="border-right: gray 1px solid; border-top: gray 1px solid; border-left: gray 1px solid;
width: 100px; border-bottom: gray 1px solid; background-color: lightgrey; text-align: center; color: silver;" id="Medium">
<span style="font-size: 10pt; font-family: Tahoma">
Medium</span></td>
<td style="border-right: gray 1px solid; border-top: gray 1px solid; border-left: gray 1px solid;
width: 100px; border-bottom: gray 1px solid; color: silver; background-color: lightgrey; text-align: right;" id="Powerful">
<span style="font-size: 10pt; font-family: Tahoma">
Powerful</span></td>
</tr>
</table>

</body>
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值