<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function CharMode(ch){
if (ch>=48 && ch <=57) //数字
return 1;
if (ch>=65 && ch <=90) //大写字母
return 2;
if (ch>=97 && ch <=122) //小写
return 4;
else
return 8; //特殊字符
}
function bitTotal(num){
var modes=0;
for (i=0;i<4;i++){
if (num & 1) modes++;
num>>>=1;
}
return modes;
}
function checkStrong(pwd){ //返回密码的强度级别
if(pwd.length < 6)
return 0;
var Modes=0;
for (i=0;i<pwd.length;i++){
//测试每一个字符的类别并统计一共有多少种模式.
Modes |= CharMode(pwd.charCodeAt(i));
}
return bitTotal(Modes);
}
function pwStrength(pwd){
var O_color="#eeeeee";
var L_color="#FF0000";
var M_color="#FF9900";
var H_color="#33CC00";
if (pwd==null||pwd==''){
Lcolor=Mcolor=Hcolor=O_color;
}else {
var S_level=checkStrong(pwd);
switch(S_level) {
case 0:
Lcolor=Mcolor=Hcolor=O_color;
case 1:
Lcolor=L_color;
Mcolor=Hcolor=O_color;
break;
case 2:
Lcolor=Mcolor=M_color;
Hcolor=O_color;
break;
default:
Lcolor=Mcolor=Hcolor=H_color;
}
}
document.getElementById("strength_L").style.background=Lcolor;
document.getElementById("strength_M").style.background=Mcolor;
document.getElementById("strength_H").style.background=Hcolor;
return;
}
</script>
</head>
<body>
<form name=form1 action="" >
输入密码:
<input type=password size=30 maxlength="20" onKeyUp=pwStrength(this.value) onBlur=pwStrength(this.value)>
<br>密码强度:
<table width="217" border="1" cellspacing="0" cellpadding="1" bordercolor="#cccccc" height="23" style='display:inline'>
<tr align="center" bgcolor="#eeeeee">
<td width="33%" id="strength_L">弱</td>
<td width="33%" id="strength_M">中</td>
<td width="33%" id="strength_H">强</td>
</tr>
</table>
</form><hr/>
<div id="num"></div>
</body>
</html>
分享到:
相关推荐
使用ASP.NET 开发,前台使用JS判断密码强度,显示密码强度和提示,并控制按钮是否启用。后台使用C#和正值表达式再次判断密码强度。
JS如何判断密码强度 本程序按以下的方式进行评估. 1.如果密码少于5位,那么就认为这是一个弱密码. 2.如果密码只由数字、小写字母、大写字母或其它特殊符号当中的一种组成,则认为这是一个弱密码. 3.如果密码由数字...
JavaScript 密码强度判断代码,支持下~~
JS判断密码强度文库.pdf
QQ密码强度判断,javascript 代码自动判断文本框中的密码强度
vue.js表单密码强度验证代码是一款适用于手机注册表单输入密码强度验证特效。
JavaScript密码强度检测JavaScript密码强度检测
js判断用户名密码实现登录
本文实例为大家分享了js判断密码强度的具体代码,供大家参考,具体内容如下 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <...
用javascript来判断输入密码的强弱程度
打开即可运行,查看代码 自己研究哈...
jsp密码强度检测jsp密码强度检测jsp密码强度检测
js判断密码的强度,给出强弱返回值,下载后,保存格式为html格式即可。
密码强度测试 javascript实现的密码强度测试 javascript实现的密码强度测试 javascript实现的密码强度测试
一个非常好用的js密码强度验证 一看即会~~!
用JavaScript来实现密码强度颜色改变
使用JS检测输入的密码强度,可以独立于HTML页面,测试文件将其写在一起,需要的读者可以分开测试
JS密码强度提示代码。简单#user_registration { border:1px solid #cccccc; margin:auto auto; margin-top:100px; width:400px; }
javascript注册密码强度检查 简单密码 一般密码 加强型密码测试