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="检测提示:" + msg[id];
}
//定义检测函数,返回0/1/2/3分别代表无效/差/一般/强
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>
</body>
</html>
使用方法:
第一步:保存图片
第二步:根据您的需要修改js文件中该图片地址。如下所示:
第三步:在需要检测的页面中引用这个脚本文件,如下所示:
<script type="text/javascript" src="chkpwd.js"></script>
第四步:在网页的表单中,找到密码输入框添加onblur事件驱动,然后添加一个Div,如下所示:
第五步:根据您页面的需要通过样式表css重新定义#chkResult的摆放位置,以合适您网页的整体布局。