jquery 密码强度验证实例
本文章提供的这款密码强度检测程序是一款利用了jquery表单插件来实例的jquery 密码强度验证,他还能自动生成随机密码。
<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>jquery 密码强度验证实例</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/网页特效"></script>
<script src="js/jquery.passwordstrength.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var $pwd = $('input[name="password"]');
$pwd.passwordstrength();
$(".generate_password").click(function(){
//产生随机八位密码
var pwd = $.passwordstrength.getrandompassword(8);
//将随机密码写入密码框,并触发验证
$pwd.val(pwd).trigger("keyup");
return false;
})
$(".get_password").click(function(){
alert($pwd.val());
return false;
})});
</script>
<link href="style/css教程/password_strength.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body{font-size:12px;}
.clearfix:after{
content:"."; display:block; height:0; clear:both;
visibility:hidden;
}
*html .clearfix{
height:1%;
}
*+html .clearfix{
height:1%;
}
.l{float:left;}
.form_item{margin-bottom:6px;}
.form_item label{width:100px;text-align:right;margin-right:4px;display:block;float:left;padding-top:2px;}
.form_item .text{height:14px;padding:2px;width:132px;border:1px solid #999;}
.form_item div a{margin-left:6px;}
#passwordstrengthdiv{margin-top:6px;}
</style>
</head><body>
<div class="form_item clearfix">
<label>密 码:</label>
<div class="l">
<div><input type="password" name="password" class="text"/><a href="" class="generate_password">产生随机密码</a><a href="" class="get_password">获取密码值</a></div>
<div id="passwordstrengthdiv" class="is0"></div>
</div>
</div>
<div class="form_item clearfix">
<label>确认密码:</label>
<div class="l">
<div><input type="password" name="confirm_password" class="text"/></div>
</div>
</div>
</body>
</html>
源码下载
http://down.zzzyk.com/down/code/jquery/2010/0909/20707.html
效果预览
http://g.226511.cn/javascript/js/20100909/jquerypwd/
补充:网页制作,jquery