现在的位置: 首页 > web前端 > 正文

密码强度检测:passwordStrength

2020年02月12日 web前端 ⁄ 共 755字 ⁄ 字号 评论关闭

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

使用很简单。

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


创建如下html代码:

<p><label>请输入密码:</label> <input type="password" id="pass" class="input" /></p> <p id="passwordStrengthDiv" class="is0"></p> <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>

以上就上有关密码强度检测:passwordStrength的全部内容,学步园全面介绍编程技术、操作系统、数据库、web前端技术等内容。

抱歉!评论已关闭.