jQuery實(shí)現(xiàn)注冊會員時密碼強(qiáng)度提示信息功能示例
本文實(shí)例講述了jQuery實(shí)現(xiàn)注冊會員時密碼強(qiáng)度提示信息功能。分享給大家供大家參考,具體如下:
1.效果如圖所示:

2.html代碼:
<p><span>設(shè)置密碼:</span><input type="password" id="external_regist_password1" name="password1" value="" /><b>*</b>
<span id="password1_bg" class="bg_rt" style="display:none"></span>
</p>
<p class="mima_qd" id="password1_strength" style="display:none">
<span class="mm_strength"><em>密碼強(qiáng)度</em>
<i class="password_qd">
<span class="password_bg" id="strength_L"></span>
<span class="password_bg" id="strength_M"></span>
<span class="password_bg" id="strength_H"></span>
</i>
<em id="pw_check_info"></em>
</span>
</p>
<p class="tishi_wr" id="password1_info"></p>
3.jquery代碼:
//checkStrong函數(shù)
//返回密碼的強(qiáng)度級別
function checkStrong(sPW){
if (sPW.length<=4)
return 0; //密碼太短
var Modes=0;
for (i=0;i<sPW.length;i++){
//測試每一個字符的類別并統(tǒng)計(jì)一共有多少種模式.
//charCodeAt():返回unicode編碼的值
Modes|=CharMode(sPW.charCodeAt(i)); //測試某個字符屬于哪一類
}
return bitTotal(Modes);//計(jì)算出當(dāng)前密碼當(dāng)中一共有多少種模式
}
//CharMode函數(shù)
//測試某個字符是屬于哪一類.
function CharMode(iN){
if (iN>=48 && iN <=57) //數(shù)字
return 1;
if (iN>=65 && iN <=90) //大寫字母
return 2;
if (iN>=97 && iN <=122) //小寫
return 4;
else
return 8; //特殊字符
}
//bitTotal函數(shù)
//計(jì)算出當(dāng)前密碼當(dāng)中一共有多少種模式
function bitTotal(num){
var modes=0;
for (i=0;i<4;i++){
if (num & 1) modes++;
num>>>=1;
}
return modes;
}
//pwStrength函數(shù)
//當(dāng)用戶放開鍵盤或密碼輸入框失去焦點(diǎn)時,根據(jù)不同的級別顯示不同的顏色
function pwStrength(pwd){
var O_color="#eeeeee";
var L_color="#FF4040";
var M_color="#FF9900";
var H_color="#33CC00";
var info = "";
if (pwd==null||pwd==''){
Lcolor=Mcolor=Hcolor=O_color;
} else {
S_level=checkStrong(pwd);//檢測密碼的強(qiáng)度
switch(S_level) {
case 0:
Lcolor=L_color;
Mcolor=Hcolor=O_color;
info = "弱";
break;
case 1:
Lcolor=L_color;
Mcolor=Hcolor=O_color;
info = "弱";
break;
case 2:
Lcolor=Mcolor=M_color;
Hcolor=O_color;
info = "中";
break;
default:
Lcolor=Mcolor=Hcolor=H_color;
info = "強(qiáng)";
}
}
$("#strength_L").css("background", Lcolor);
$("#strength_M").css("background", Mcolor);
$("#strength_H").css("background", Hcolor);
$("#pw_check_info").html(info);//密碼強(qiáng)度提示信息
return;
}
PS:這里再為大家提供兩款相關(guān)在線工具供大家參考使用:
密碼安全性在線檢測:
http://tools.jb51.net/password/my_password_safe
高強(qiáng)度密碼生成器:
http://tools.jb51.net/password/CreateStrongPassword
在線隨機(jī)數(shù)字/字符串生成工具:
http://tools.jb51.net/aideddesign/suijishu
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery form操作技巧匯總》、《jQuery常見事件用法與技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery表格(table)操作技巧匯總》及《jquery選擇器用法總結(jié)》
希望本文所述對大家jQuery程序設(shè)計(jì)有所幫助。
- 基于JQuery的密碼強(qiáng)度驗(yàn)證代碼
- jquery判斷密碼強(qiáng)度的驗(yàn)證代碼
- jQuery判斷密碼強(qiáng)度實(shí)現(xiàn)思路及代碼
- passwordStrength 基于jquery的密碼強(qiáng)度檢測代碼使用介紹
- jquery密碼強(qiáng)度校驗(yàn)
- jQuery實(shí)現(xiàn)提示密碼強(qiáng)度的代碼
- jQuery密碼強(qiáng)度檢測插件passwordStrength用法實(shí)例分析
- jQuery插件passwordStrength密碼強(qiáng)度指標(biāo)詳解
- jQuery密碼強(qiáng)度驗(yàn)證控件使用詳解
- jQuery實(shí)用密碼強(qiáng)度檢測
相關(guān)文章
easyui中combotree循環(huán)獲取父節(jié)點(diǎn)至根節(jié)點(diǎn)并輸出路徑實(shí)現(xiàn)方法
下面小編就為大家?guī)硪黄猠asyui中combotree循環(huán)獲取父節(jié)點(diǎn)至根節(jié)點(diǎn)并輸出路徑實(shí)現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-11-11
深入理解JQuery keyUp和keyDown的區(qū)別
這篇文章主要是對JQuery中keyUp與keyDown的區(qū)別進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以過來參考下,希望對大家有所幫助2013-12-12
jQuery動畫效果animate和scrollTop結(jié)合使用實(shí)例
animate是jq的一個特效的函數(shù)方法,animate() 方法執(zhí)行 CSS 屬性集的自定義動畫。該方法通過CSS樣式將元素從一個狀態(tài)改變?yōu)榱硪粋€狀態(tài)。2014-04-04
jQuery實(shí)現(xiàn)用方向鍵控制層的上下左右移動
本文將會使用jquery實(shí)現(xiàn)以下功能:按下方向鍵時,使層向相應(yīng)的方向平滑移動20像素;四個方向鍵的鍵碼分別是37(左)、38(上)、39(右)和40(下),感興趣的朋友可以了解下2013-01-01
Jquery Validation插件防止重復(fù)提交表單的解決方法
在項(xiàng)目開發(fā)中,測試人員報(bào)告缺陷說,即時有表單驗(yàn)證,但是如果快速點(diǎn)擊兩下“提交”按鈕,系統(tǒng)會產(chǎn)生兩條相同的記錄。2010-03-03
Jquery中LigerUi的彈出編輯框(實(shí)現(xiàn)方法)
本篇文章是對Jquery中LigerUi的彈出編輯框的實(shí)現(xiàn)方法進(jìn)行了分析介紹,需要的朋友可以參考下2013-07-07

