我们设定密码强度等级为10,制作一张图片表示每个等级状态,给密码框绑定keyup事件,通过keyup事件获取密码值,然后使用正则进行判断密码强度等级,然后变换相应的图片。
使用很简单。
$('#pass').passwordStrength();
查看演示demo,下载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'
载入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.com和作者拥有版权,如需转载,请注明来源于
helloweba.com并保留原文链接,否则视为侵权。
分享到:
相关推荐
Jquery插件之密码强度检测:passwordStrength
主要介绍了jQuery密码强度检测插件passwordStrength用法,以一个完整实例形式较为详细的分析了passwordStrength插件针对密码强度的检测方法,需要的朋友可以参考下
jQuery+passwordStrength密码强度检测
passwordStrength的密码强度检测
passwordStrength 基于jquery的密码强度检测.zip
jQuery实现带密码强度检测的输入框设计效果
代码如下: $(‘#pass’).passwordStrength(); XHTML 代码如下: <p><label>请输入密码:</label> <input type=”password” id=”pass” class=”input” /></p> ”passwordStrengthDiv” class=”is0″>...
总览一种检查某个密码短语的密码强度的简单方法。 基于密码强度检查器。安装npm i check-password-strength --save 设置和基本用法const passwordStrength = require('check-password-strength')console.log...