密码强度检测:passwordStrength

原创文章 作者:月光光 2010年09月10日 16:13helloweba.com 标签:jQuery 

我们设定密码强度等级为10,制作一张图片表示每个等级状态,给密码框绑定keyup事件,通过keyup事件获取密码值,然后使用正则进行判断密码强度等级,然后变换相应的图片。

密码强度检测:passwordStrength

使用很简单。

$('#pass').passwordStrength();

创建如下html代码:

<p><label>请输入密码:</label>
 <input type="password" id="pass" class="input" /></p>
 <div id="passwordStrengthDiv" class="is0"></div> 
 <p><label>确认密码:</label>
 <input type="password" id="repass" class="input" /></p>

注意:id#passwordStrengthDiv的DIV是用来加载强度图片的,你也可以自定义ID,但调用时就要给参数赋值:

targetDiv : '#ID' //自定义加载图片的ID

载入JS和CSS:

<link rel="stylesheet" type="text/css" href="style/main.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.passwordStrength.js"></script>
<script type="text/javascript">
$(function(){
	$('#pass').passwordStrength();
});
</script>
声明:本文为原创文章,helloweba.net和作者拥有版权,如需转载,请注明来源于helloweba.net并保留原文链接:https://www.helloweba.net/javascript/50.html

4条评论

  • 应该添加点 强度提示 提示就更完美了··

  • 很好 赞个

  • 测试下[神马]

  • 貌似没给图片啊。。