JS验证密码强度
CSS代码
<style type="text/css">
.pwd-strength {width:180px;height:20px;line-height:20px}
.pwd-strength-box,.pwd-strength-box-low,.pwd-strength-box-med,.pwd-strength-box-hi{color: #464646;text-align: center;
width: 30%; float:left; border:solid 1px #CCCCCC}
.pwd-strength-box-low{color: #FF0000;background-color:#F00F00;color:#FFFFFF}
.pwd-strength-box-med{color: #FF0000;background-color: #CCCCCC;}
.pwd-strength-box-hi{color: #FF0000;background-color: #FF9900;}
</style>
Html代码
<table width="390" border="0" cellspacing="0" cellpadding="0" class="bgFormStyle_l">
<tr>
<td width="63" height="29" align="center" class="c_999"><span class="p_l5">重复密码</span></td>
<td><input type="password" id="NewPass" name="NewPass" class="input310" maxlength="20" onKeyUp="checkPassword(this.value);"></td>
<td width="5" height="29" class="bgFormStyle_r"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="12" valign="top">
<div class="pwd-strength FCK__ShowTableBorders" style="display:none;">
<div class="pwd-strength-box" id="pwdLow4">低</div>
<div class="pwd-strength-box" id="pwdMed4">等</div>
<div class="pwd-strength-box" id="pwdHi4">高</div>
</div>
</td>
</tr>
</table>
JS代码:
<script language="javascript" type="text/javascript">
function CheckForm()
{
if ($("#UserPass").val()=="")
{
alert("\u5f53\u524d\u767b\u5f55\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a\u3002");
$("#UserPass").focus();
return false;
}
if ($("#NewPass").val()=="")
{
alert("\u65b0\u7684\u767b\u5f55\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a\u3002");
$("#NewPass").focus();
return false;
}
if ($("#NewPass1").val()=="")
{
alert("\u8bf7\u518d\u6b21\u8f93\u5165\u65b0\u7684\u767b\u5f55\u5bc6\u7801\u3002");
$("#NewPass1").focus();
return false;
}
if ($("#NewPass").val()!=$("#NewPass1").val())
{
alert("\u4e24\u6b21\u5bc6\u7801\u8f93\u5165\u4e0d\u4e00\u81f4\u3002");
$("NewPass1").focus();
return false;
}
return true;
}
</script>