模仿美团的美化

<!DOCTYPE>
<head runat="server">
<title></title>
<link rel="stylesheet" type="text/css" href="mima.css">
<script src="jquery-1.9.0.min.js"></script>
<script src="MeForCopy.js"></script>
</head>
<body>
<form name="form1" action="">
<input type="password" size="10" id="password">
<br>
<div class="pw-strength">
<div id="J-pw-strength__bar" class="pw-strength__bar"></div>
<div class="pw-strength__letter">
<span class="pw-strength__label">L</span>
<span class="pw-strength__label">M</span>
<span class="pw-strength__label pw-strength__label--noborder">H</span>
</div>
</div>
<div id="msg"></div>
</form>
</body>
</html>

JS

  $(function() {
$("#password").blur(function(event) {
/* Act on the event */
var psw = $(this).val(); //okay
pwStrength(psw);
});
$("#password").keyup(function(event) {
/* Act on the event */
var psw = $(this).val(); //okay
pwStrength(psw);
});
}); function pwStrength(psw) {
if (psw == '') {
$("#msg").text('no');
$(".pw-strength__bar").removeAttr('class').addClass('pw-strength__bar');
} else {
S_level = checkStrong(psw);
switch (S_level) {
case 0:
$("#msg").text('no');
$(".pw-strength__bar").removeAttr('class').addClass('pw-strength__bar');
case 1:
$("#msg").text('weak');
$(".pw-strength__bar").removeAttr('class').addClass('pw-strength__bar').addClass('pw-strength__bar--weak');
break;
case 2:
$("#msg").text('normal');
$(".pw-strength__bar").removeAttr('class').addClass('pw-strength__bar').addClass('pw-strength__bar--normal');
break;
default:
$("#msg").text('Strong');
$(".pw-strength__bar").removeAttr('class').addClass('pw-strength__bar').addClass('pw-strength__bar--strong');
}
}
} function checkStrong(sPW) {
if (sPW.length <= 4) {
return 0; //密码太短
}
Modes = 0;
for (i = 0; i < sPW.length; i++) {
//测试每一个字符的类别并统计一共有多少种模式.
Modes |= CharMode(sPW.charCodeAt(i));
}
return bitTotal(Modes);
} //CharMode函数
//测试某个字符是属于哪一类.
function CharMode(iN) {
if (iN >= 48 && iN <= 57) //数字
return 1;
if (iN >= 65 && iN <= 90) //大写字母
return 2;
if (iN >= 97 && iN <= 122) //小写
return 4;
else
return 8; //特殊字符
}
//bitTotal函数
//计算出当前密码当中一共有多少种模式
function bitTotal(num) {
modes = 0;
for (i = 0; i < 4; i++) {
if (num & 1) modes++;
num >>>= 1;
}
return modes;
}

CSS

.pw-strength {
background: none repeat scroll 0 0 #C9E0DD;
left: 80px;
position: absolute;
top: 45px;
width: 234px;
} .pw-strength__bar {
background: none repeat scroll 0 0 #C9E0DD;
height: 16px;
overflow: hidden;
width:;
-moz-transition: all 0.4s linear 0s;
transition: all .4s linear;
-webkit-transition: all .4s linear;
-moz-transition: all .4s linear;
-o-transition: all .4s linear;
} .pw-strength__letter {
left:;
position: absolute;
top:;
} .pw-strength__bar--normal {
background: none repeat scroll 0 0 #F1D93A;
width: 154px;
} .pw-strength__bar--weak {
background: none repeat scroll 0 0 #EA9292;
width: 76px;
} .pw-strength__bar--strong {
background: none repeat scroll 0 0 #5AAC47;
width: 232px;
} .pw-strength__label {
border-right: 2px solid #FFFFFF;
color: #FFFFFF;
display: block;
float: left;
font-size: 12px;
height: 16px;
line-height: 16px;
text-align: center;
width: 76px;
}

javascript 检测密码强度 美化版的更多相关文章

  1. javascript 检测密码强度

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. JS正则检测密码强度

    今天遇到个需求,使用JS检测密码强度:密码长度最短为8,必须同时包含字母.数字.特殊符号. 代码如下: /*         * 检测密码复杂度         */         function ...

  3. JavaScript判断密码强度

    以下是代码: <html> <head> <title>JS判断密码强度</title> <script language=javascript& ...

  4. JavaScript验证密码强度

    JavaScript的方法: <script type="text/javascript"> window.onload = function () { documen ...

  5. js检测密码强度

    <script> function AuthPasswd(string) {     if(string.length >=6) {         if(/[a-zA-Z]+/.t ...

  6. [No0000CE]检测非空格字符作为密码的密码强度

    Regex.Replace(pwd, "^(?:([a-z])|([A-Z])|([0-9])|(.)){6,}|(.)+$", "$1$2$3$4$5").L ...

  7. js动态判断密码强度&&实用的 jQuery 代码片段

    // 网上拷贝的代码,效果不太好需要自己调整<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &q ...

  8. js密码强度

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. 密码强度应用(js)

    <!-- 密码强度div --> <div id="tips" class="help-block"> <b class=&quo ...

随机推荐

  1. Poj 3517 And Then There Was One(约瑟夫环变形)

    简单说一下约瑟夫环:约瑟夫环是一个数学的应用问题:已知n个人(以编号1,2,3...n分别表示)围坐在一张圆桌周围.从编号为k的人开始报数,数到m的那个人出列:他的下一个人又从1开始报数,数到m的那个 ...

  2. Html中截切文章内容,造成标签不全的问题

    把标签全部进行替换 ) { string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+ ...

  3. Hadoop 相关问题

    1.MR Job 输入非常多,启动map 非常多,如何提高MapTask 启动速度(附加条件:集群很空闲,资源多多): 参考答案: a.重写调度器算法,降低时间复杂度 b.Out-of-bound h ...

  4. PHP CI框架最近学到的内容

    CI框架配置方面注意的细节 在config里面的database.php里面是和数据库配置相关的内容 $db['default'] = array( 'dsn' => '', 'hostname ...

  5. Python学习笔记 (3) :列表、元组的操作

    列表,即写在方括号之间.用逗号分隔开的数值列表.列表内的项目不必全是相同的类型. >>> a = ['spam', 'eggs', 100, 1234] >>> a ...

  6. TexturePacker

    TexturePacker 可以免费申请,希望可以申请到.

  7. android-意图Intent

    Android基本的设计理念是鼓励减少组件间的耦合,因此Android提供了Intent (意图) ,Intent提供了一种通用的消息系统,它允许在你的应用程序与其它的应用程序间传递 Intent 来 ...

  8. ASP.NET JQuery Ajax 详解

    在.NET中使用Ajax请求,我们可以使用一般处理程序,或者Web服务,还有一种是使用后台的Web方法(注意:当我们使用后台的Web方法是,后台方法必须加可访问性必须为: public,且为stati ...

  9. wordpress模板制作第一课

    一套完整的WordPress模板应至少具有如下文件: style.css : CSS(样式表)文件 index.php : 主页模板 archive.php : Archive/Category模板 ...

  10. ImageMagick还是GraphicsMagick?

    引自:http://co63oc.blog.51cto.com/904636/328997 ImageMagick(IM) 套装包含的命令行图形工具是一主要自由软件:Linux,其他类Unix操作系统 ...