需要用到两个脚本,直接从 MSN 网站保存即可: PPPrimary.js (一些常用函数等) pswdplc.js (密码验证过程中的函数) 下载附件,将 .rar 的扩展名修改为 .js 即可。 对应的 HTML 代码 (简单示例)(在线演示) : HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>密码安全性验证</title> <script language="javascript" type="text/javascript" src="pswdplc.js"></script> <script language="javascript" type="text/javascript" src="PPPrimary.js"></script> <style type="text/css"> .css0027,.css0061,.css0063 {color:#6E6E6E;} .css0162 {background-color:#EBEBEB;border-right:solid 1px #BEBEBE;border-bottom:solid 1px #BEBEBE;} .css0163 {background-color:#FF4545;border-right:solid 1px #BB2B2B;border-bottom:solid 1px #BB2B2B;} .css0164 {background-color:#FFD35E;border-right:solid 1px #E9AE10;border-bottom:solid 1px #E9AE10;} .css0165 {background-color:#3ABB1C;border-right:solid 1px #267A12;border-bottom:solid 1px #267A12;} </style> </head> <body> <form> <label>密码:</label><input name="password" id="password" maxlength="16" autocomplete="off" value="" style="" class="css0081" onkeyup="javascript:SetPwdStrengthEx(document.forms[0],this.value);" onmouseout="javascript:SetPwdStrengthEx(document.forms[0],this.value);" onblur="javascript:SetPwdStrengthEx(document.forms[0],this.value);" type="password"> <span class="css0061">至少 6 个字符,不包括空格</span> <br> <br> <script type="text/javascript">function DispPwdStrength(iN,sHL){ if(iN>3){ iN=3;}for(var i=0;i<4;i++){ var sHCR="css0162";if(i<=iN){ sHCR=sHL;}if(i>0){ GEId("idSM"+i).className=sHCR;}GEId("idSMT"+i).style.display=((i==iN)?"inline":"none");}}</script> <table class="css0161" style="height: 19px;" cellpadding="0" cellspacing="0" width="200"> <tbody> <tr> <td id="idSM1" class="css0163" align="center" width="33%"><span style="font-size: 1px;"> </span><span id="idSMT1" style="display: inline;">弱</span></td> <td id="idSM2" class="css0162" style="border-left: 1px solid rgb(255, 255, 255);" align="center" width="34%"><span style="font-size: 1px;"> </span><span id="idSMT0" style="display: none; font-weight: normal; color: rgb(102, 102, 102);">未能评级</span><span id="idSMT2" style="display: none;">中</span></td> <td id="idSM3" class="css0162" style="border-left: 1px solid rgb(255, 255, 255);" align="center" width="33%"><span style="font-size: 1px;"> </span><span id="idSMT3" style="display: none;">强</span></td> </tr> </tbody> </table> </form> </body> </html>