zoukankan
html css js c++ java
检验密码强度的JS类
<
script type
=
"
text/javascript
"
>
var
PasswordStrength
=
{
Level : [
"
高,实在是高
"
,
"
还行啦
"
,
"
靠,这样也行
"
],
LevelValue : [
30
,
20
,
0
],
//
强度值
Factor : [
1
,
2
,
5
],
//
字符加数,分别为字母,数字,其它
KindFactor : [
0
,
0
,
10
,
20
],
//
密码含几种组成的加数
Regex : [
/
[a
-
zA
-
Z]
/
g,
/
\d
/
g,
/
[
^
a
-
zA
-
Z0
-
9
]
/
g]
//
字符正则数字正则其它正则
}
PasswordStrength.StrengthValue
=
function
(pwd)
{
var
strengthValue
=
0
;
var
ComposedKind
=
0
;
for
(
var
i
=
0
; i
<
this
.Regex.length;i
++
)
{
var
chars
=
pwd.match(
this
.Regex[i]);
if
(chars
!=
null
)
{
strengthValue
+=
chars.length
*
this
.Factor[i];
ComposedKind
++
;
}
}
strengthValue
+=
this
.KindFactor[ComposedKind];
return
strengthValue;
}
PasswordStrength.StrengthLevel
=
function
(pwd)
{
var
value
=
this
.StrengthValue(pwd);
for
(
var
i
=
0
; i
<
this
.LevelValue.length ; i
++
)
{
if
(value
>=
this
.LevelValue[i] )
return
this
.Level[i];
}
}
alert(PasswordStrength.StrengthLevel(
"
23
"
));
alert(PasswordStrength.StrengthLevel(
"
abcd123
"
));
alert(PasswordStrength.StrengthLevel(
"
abcd!%23
"
));
</
script
>
查看全文
相关阅读:
[转]Hello ActiveMQ
Access中合并两张表为一张表
infragistics ultraGrid单元格、行只读
(转)c#中对"Crossthread operation not valid"错误的处理办法
[LintCode] String Homomorphism Review
[LintCode] Longest Increasing Continuous Subsequence Review
[LintCode] Longest Increasing Continuous subsequence II Review
[LintCode] Coins in a Line II Review
标准的SQL的解析顺序
SQLServer 存储过程 SET NOCOUNT { ON | OFF } 的使用(转载)
原文地址:https://www.cnblogs.com/xiang/p/400164.html
最新文章
Python 模仿Cat功能
Python try_finally
Python 自定义异常
一个小想法(学Python的目标)
NSKeyedArchiver的基础用法
隐藏TableView中Cell与Cell之间的border
修改 UITableview 滚动条颜色的方法
UIEdgeInsets
UITableView用法总结
NavigationViewController的backBarButtonItem的设置技巧
热门文章
提醒用户_UIAlertview/UIActionsheet
Navigation Controller 模式弹出新的Navigation Controller
UIView翻译 (参考)
关于UISearchBar
[转]将第三方控件UltraWinGrid设为只读或选中整行
我们的回忆
[转]动态添加ContextMenuStrip项(ToolStripItem)
Eclipse RCP 导出部署后不能启动
[转]C#创建右键菜单
HttpClient登陆开心网
Copyright © 2011-2022 走看看