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

查看示例:DEMO

密码强度检测:passwordStrength

使用很简单。

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

XHTML

  1. <p><label>请输入密码:</label>   
  2. <input type="password"  /></p>   
  3. <div ></div>    
  4. <p><label>确认密码:</label>   
  5. <input type="password"  /></p>   

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

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

载入JS和CSS:

  1. <link rel="stylesheet" type="text/css" href="style/main.css" />   
  2. <script type="text/javascript" src="jquery.js"></script>   
  3. <script type="text/javascript" src="jquery.passwordStrength.js"></script>   
  4. <script type="text/javascript">   
  5. $(function(){   
  6.     $('#pass').passwordStrength();   
  7. });   
  8. </script>  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2022-01-26
  • 2021-10-21
  • 2022-12-23
  • 2021-09-10
猜你喜欢
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
  • 2021-09-19
  • 2022-12-23
  • 2021-07-11
相关资源
相似解决方案