医调项目之DX控件的JS密码强度验证
2014-05-19 11:47
519 查看
部分内容参考:http://www.shaoqun.com/a/59656.aspx
提示框的CSS样式:
验证密码强度的JS函数:
给 客户端添加 触发事件:
如果是DX控件的话 就更简单了:
文本框添加事件代码:
JS :
提示框的CSS样式:
<style type="text/css"> #DivTips { float: left; margin: 2px 0 0 20px; } #DivTips span { float: left; width: 50px; height: 20px; color: #fff; overflow: hidden; background: #ccc; margin-right: 2px; line-height: 20px; text-align: center; } #DivTips.s1 .active { background: #f30; } #DivTips.s2 .active { background: #fc0; } #DivTips.s3 .active { background: #cc0; } #DivTips.s4 .active { background: #090; } </style>
验证密码强度的JS函数:
//检测密码强度 function checkStrong(sValue) { var modes = 0; if (sValue.length < 6) return modes; if (/\d/.test(sValue)) modes++; //数字 if (/[a-z]/.test(sValue)) modes++; //小写 if (/[A-Z]/.test(sValue)) modes++; //大写 if (/\W/.test(sValue)) modes++; //特殊字符 switch (modes) { case 1: return 1; break; case 2: return 2; case 3: case 4: return sValue.length < 12 ? 3 : 4 break; } }
给 客户端添加 触发事件:
<script type="text/javascript"> window.onload = function () { var oTips = document.getElementById("tips"); var oInput = document.getElementsByTagName("input")[0]; var aSpan = oTips.getElementsByTagName("span"); var aStr = ["弱", "中", "强", "非常好"]; var i = 0; oInput.onkeyup = oInput.onfocus = oInput.onblur = function () { var index = checkStrong(this.value); this.className = index ? "correct" : "error"; oTips.className = "s" + index; for (i = 0; i < aSpan.length; i++) aSpan[i].className = aSpan[i].innerHTML = ""; index && (aSpan[index - 1].className = "active", aSpan[index - 1].innerHTML = aStr[index - 1]) } };
如果是DX控件的话 就更简单了:
文本框添加事件代码:
<ClientSideEvents KeyUp="function(s, e) { CheckComposerPw() }" />
JS :
function CheckComposerPw() { var oTips = document.getElementById("DivTips"); var aSpan = oTips.getElementsByTagName("span"); var aStr = ["弱", "中", "强", "非常好"]; var i = 0; var index = checkStrong(txtComposerPwd.GetText()); this.className = index ? "correct" : "error"; oTips.className = "s" + index; for (i = 0; i < aSpan.length; i++) aSpan[i].className = aSpan[i].innerHTML = ""; index && (aSpan[index - 1].className = "active", aSpan[index - 1].innerHTML = aStr[index - 1]); }
相关文章推荐
- 客户端验证密码强度的JS
- JS密码强度验证(兼容IE,火狐,谷歌) -- 仿JQuery中文社区注册
- JS密码强度验证
- js实现密码强度验证(显示强度,仿CSDN注册页面的密码验证)
- js在客户端验证密码强度,兼容FireFox和IE
- 验证密码强度的js
- JS验证密码强度插件
- js密码强度验证
- js实现密码强度验证
- JS密码强度验证(兼容IE,火狐,谷歌) -- 仿JQuery中文社区注册
- js验证密码安全强度
- 用js实现密码强度验证
- JS验证密码的强度
- 验证密码强度js代码
- JS 密码强度验证(兼容IE,火狐,谷歌)
- 使用JS验证密码的强度
- js验证身份证号码的有效方法[1]以及密码验证和强度的验证 1 JS正则表达式 代码 .txt
- js在客户端验证密码强度,兼容FireFox和IE
- js实现密码强度验证
- js用户密码强度验证函数