PHP速学视频免费教程(入门到精通)
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
本文主要和大家分享JS实现密码弱中强显示,主要以代码的方式和大家分享,希望能帮助到大家。
nbsp;html> <meta> <title></title> <meta> <script> onload = function () { var tds = document.getElementById('tb').getElementsByTagName('td'); document.getElementById('txt').onkeyup = function () { for (var i = 0; i < tds.length; i++) {//防止输入正确密码后倒退删除时候出问题 tds[i].style.backgroundColor = 'gray'; } if (this.value.length>0) { var result = checkPwd(this.value); if (result<=1) {//弱 tds[0].style.backgroundColor='red'; }else if (result==2) {//中 tds[0].style.backgroundColor='green'; tds[1].style.backgroundColor='green'; }else if (result==3) {//强 tds[0].style.backgroundColor='blue'; tds[1].style.backgroundColor='blue'; tds[2].style.backgroundColor='blue'; } } } } function checkPwd(msg){ //判断含有数字字母特殊符号 var lvl = 0; if (msg.match(/[0-9]/)){ lvl++; } if (msg.match(/[a-zA-Z]/)) { lvl++; } if (msg.match(/[^0-9a-zA-Z]/)) { lvl++; } if (msg.length<6) { lvl--; } return lvl; } </script> <input>
弱 | 中 | 强 |
相关推荐:
已抢6861个
抢已抢92183个
抢已抢14485个
抢已抢50772个
抢已抢191299个
抢已抢86489个
抢