jQuery實(shí)現(xiàn)注冊會(huì)員時(shí)密碼強(qiáng)度提示信息功能示例
本文實(shí)例講述了jQuery實(shí)現(xiàn)注冊會(huì)員時(shí)密碼強(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)度級(jí)別 function checkStrong(sPW){ if (sPW.length<=4) return 0; //密碼太短 var Modes=0; for (i=0;i<sPW.length;i++){ //測試每一個(gè)字符的類別并統(tǒng)計(jì)一共有多少種模式. //charCodeAt():返回unicode編碼的值 Modes|=CharMode(sPW.charCodeAt(i)); //測試某個(gè)字符屬于哪一類 } return bitTotal(Modes);//計(jì)算出當(dāng)前密碼當(dāng)中一共有多少種模式 } //CharMode函數(shù) //測試某個(gè)字符是屬于哪一類. 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)時(shí),根據(jù)不同的級(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é)》
希望本文所述對(duì)大家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)文章
jQuery實(shí)現(xiàn)拖拽頁面元素并將其保存到cookie的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)拖拽頁面元素并將其保存到cookie的方法,涉及jQuery基于cookie針對(duì)頁面元素屬性的相關(guān)保存操作技巧,需要的朋友可以參考下2016-06-06jquery 表單進(jìn)行客戶端驗(yàn)證demo
用jquery對(duì)表單進(jìn)行客戶端驗(yàn)證demo ,學(xué)習(xí)jquery的朋友可以參考下。2009-08-08cnblogs TagCloud基于jquery的實(shí)現(xiàn)代碼
自創(chuàng)"山寨版"的"博客園"TagCloud!...2010-06-06jQuery中slideUp 和 slideDown 的點(diǎn)擊事件
這篇文章主要介紹了jQuery中slideUp 和 slideDown 的點(diǎn)擊事件的相關(guān)資料,需要的朋友可以參考下2015-02-02jQuery中select與datalist制作下拉菜單時(shí)的區(qū)別淺析
一般我們通常使用select制作下拉菜單,但是H5之后,datalist也可以充當(dāng)select的角色,而且兩者還有一點(diǎn)小的不同。具體區(qū)別詳解小編通過本文給簡單介紹下2016-12-12jQuery實(shí)現(xiàn)下拉菜單滑動(dòng)效果
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)下拉菜單滑動(dòng)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08