密码强度显示和中文强弱显示
复制代码代码如下 :
<! doctype html public "-// w3c // dtd html 4.01 Transitional // en">
<html>
<헤드>
<base href = "<%= basepath%>">
<title> 내 jsp 'a.jsp'시작 페이지 </title>
<meta http-equiv = "pragma"content = "no-cache">
<meta http-equiv = "캐시 제어"content = "no-cache">
<meta http-equiv = "만료"내용 = "0">
<meta http-equiv = "keywords"content = "keyword1, keyword2, keyword3">
<meta http-equiv = "description"content = "이것은 내 페이지입니다">
<스타일 유형 = "텍스트/CSS">
* {마진 : 0px; 패딩 : 0px;}
.j_passwordstatus {Padding-Bottom : 0px; 높이 : 18px;}
.Status-bar {margin : 0px; display : 인라인-블록; 너비 : 80px; 높이 : 5px; 패딩 : 1px; 테두리 : 1px 고체 #42bf26; 배경색 : 흰색; 수직-정렬 : 중간; font-size : 0;}
.Status-bar span {배경색 :#42bf26; 높이 : 5px; 디스플레이 : 인라인-블록;}
</스타일>
</head>
<body>
<입력 유형 = "password"id = "pwd1"style = "float : 왼쪽; 마진-탑 : 5px;" onkeyup = "checkpassword ();"/>
<div id = "p_passwordstatus"
스타일 = "디스플레이 : 없음; 너비 : 300px;">
<span> : : </span>
<span style = "text-indent : 0px;">
<span style = "line-height : 5px;"> </span>
</span>
<span> </span>
</div>
</body>
</html>
<script type = "text/javaScript"src = "jQuery-1.7.2.min.js"> </script>
<script type = "text/javaScript">
함수 checkPassword () {
var pwd = $ ( "#pwd1"). val ();
gpasswdstatus (pwd, 'p_passwordstatus');
}
함수 gpasswdstatus (value, id) {
var status = $ ( "#"+id);
var result = $ ( "#"+id) .find ( ". status-result") [0];
var bar = $ ( "#"+id) .find ( ". 상태 바 스팬");
if (value === "") {
status.css ( "display", "none");
} 또 다른 {
var score = gcheckpassword (값);
bar.css ( "width", score + "%");
var resultDesp = ggetResultDesp (score);
result.innerhtml = resultDesp;
status.css ( "display", "block");
}
}
/**
* 检验密码强度并返回得分
*
* @param {}
* 비밀번호
* @return {번호}
*/
기능 gcheckpassword (비밀번호) {
var _score = 0;
if (! password) {
반환 0
}
if (password.length <= 4) {
_score += 5
} 또 다른 {
if (password.length> = 5 && password.length <= 7) {
_score += 10
} 또 다른 {
if (password.length> = 8) {
_score += 25
}
}
}
var _upperCount = (password.match (/[az]/g) || []). 길이;
var _lowerCount = (password.match (/[az]/g) || []). 길이;
var _lowerUpperCount = _upperCount + _LowerCount;
if (_upperCount && _LowerCount) {
_score += 20
} 또 다른 {
if (_upperCount || _LowerCount) {
_score += 10
}
}
var _numberCount = (password.match (/[/d]/g, "") || []). 길이;
if (_numberCount> 0 && _numberCount <= 2) {
_score += 10
} 또 다른 {
if (_numberCount> = 3) {
_score += 20
}
}
var _characterCount = (password.match (/= !@#$%^&*?_/./- ~]/g) || []). 길이;
if (_characterCount == 1) {
_score += 10
} 또 다른 {
if (_characterCount> 1) {
_score += 25
}
}
if (_numberCount && (_upperCount && _LowerCount)
&& _characterCount) {
_score += 5
} 또 다른 {
if (_numberCount && _LowerUpperCount && _characterCount) {
_score += 3
} 또 다른 {
if (_numberCount && _LowerUpperCount) {
_score += 2
}
}
}
_Score를 반환합니다
}
/**
* 根据密码强度得分返回密码强弱度中文提示
*
* @param {}
* 점수
* @return {String}
*/
함수 ggetresultdesp (score) {
if (score <= 5) {
"/u592a/u77ed"반환
} 또 다른 {
if (점수> 5 && 점수 <20) {
반환 "/u5f31"
} 또 다른 {
if (score> = 20 && score <60) {
"/u4e2d"반환
} 또 다른 {
if (score> = 60) {
"/u5f3a"반환
} 또 다른 {
반품 ""
}
}
}
}
}
</스크립트>
以上所述就是本文给大家分享的全部内容了 以上所述就是本文给大家分享的全部内容了, 希望对大家熟练掌握 javaScript 能够有所帮助。