php判断密码强度
来源:互联网 发布:杀马特火星文 知乎 编辑:程序博客网 时间:2024/05/16 01:34
一、php页面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
$score
= 0;
if
(!
empty
(
$_GET
[
'value'
])){
//接收的值
$str
=
$_GET
[
'value'
];
}
else
{
$str
=
''
;
}
if
(preg_match(
"/[0-9]+/"
,
$str
))
{
$score
++;
}
if
(preg_match(
"/[0-9]{3,}/"
,
$str
))
{
$score
++;
}
if
(preg_match(
"/[a-z]+/"
,
$str
))
{
$score
++;
}
if
(preg_match(
"/[a-z]{3,}/"
,
$str
))
{
$score
++;
}
if
(preg_match(
"/[A-Z]+/"
,
$str
))
{
$score
++;
}
if
(preg_match(
"/[A-Z]{3,}/"
,
$str
))
{
$score
++;
}
if
(preg_match(
"/[_|\-|+|=|*|!|@|#|$|%|^|&|(|)]+/"
,
$str
))
{
$score
+= 2;
}
if
(preg_match(
"/[_|\-|+|=|*|!|@|#|$|%|^|&|(|)]{3,}/"
,
$str
))
{
$score
++ ;
}
if
(
strlen
(
$str
) >= 10)
{
$score
++;
}
echo
$score
;
exit
;
二、html页面
1
2
3
4
5
6
7
8
9
10
11
12
13
<
table
cellspacing
=
"0"
cellpadding
=
"0"
>
<
tr
>
<
td
>输入密码:</
td
>
<
td
colspan
=
"4"
><
input
type
=
"password"
value
=
""
name
=
"newpwd"
onblur
=
"getPassword();"
/>
</
tr
>
<
tr
>
<
td
>密码强度:</
td
>
<
td
id
=
"idSM1"
align
=
"middle"
width
=
"20%"
><
span
style
=
"height:0px; line-height:0px;"
> </
span
><
span
id
=
"idSMT1"
style
=
"DISPLAY: none"
>弱</
span
></
td
>
<
td
id
=
"idSM2"
style
=
"BORDER-LEFT: #fff 1px solid"
align
=
"middle"
width
=
"20%"
><
span
style
=
"height:0px; line-height:0px;"
> </
span
><
span
id
=
"idSMT0"
style
=
"DISPLAY:inline; FONT-WEIGHT: normal; COLOR: #666"
>无</
span
><
span
id
=
"idSMT2"
style
=
"DISPLAY: none"
>中等</
span
></
td
>
<
td
id
=
"idSM3"
style
=
"BORDER-LEFT: #fff 1px solid"
align
=
"middle"
width
=
"20%"
><
span
style
=
"height:0px; line-height:0px;"
> </
span
><
span
id
=
"idSMT3"
style
=
"DISPLAY: none"
>强</
span
></
td
>
<
td
id
=
"idSM4"
style
=
"BORDER-LEFT: #fff 1px solid"
align
=
"middle"
width
=
"20%"
> <
span
style
=
"height:0px; line-height:0px;"
> </
span
><
span
id
=
"idSMT4"
style
=
"DISPLAY: none"
>极好</
span
></
td
>
</
tr
>
</
table
>
三、js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<script>
function
getPassword(){
var
value = $(
"input[name='newpwd']"
).attr(
'value'
);
$.get(
'index.php?r=account/testpwd'
,{value:value},
function
(data){
if
(data>=1 && data<=3){
$(
'#idSM1'
).attr(
'class'
,
'pwdChkCon1'
);
//弱
$(
'#idSM2'
).attr(
'class'
,
'pwdChkCon0'
);
$(
'#idSM3'
).attr(
'class'
,
'pwdChkCon0'
);
$(
'#idSM4'
).attr(
'class'
,
'pwdChkCon0'
);
$(
'#idSMT1'
).show();
$(
'#idSMT0'
).hide();
$(
'#idSMT2'
).hide();
$(
'#idSMT3'
).hide();
$(
'#idSMT4'
).hide();
}
else
if
(data>=4 && data<=6){
//中等
$(
'#idSM1'
).attr(
'class'
,
'pwdChkCon2'
);
$(
'#idSM2'
).attr(
'class'
,
'pwdChkCon2'
);
$(
'#idSM3'
).attr(
'class'
,
'pwdChkCon0'
);
$(
'#idSM4'
).attr(
'class'
,
'pwdChkCon0'
);
$(
'#idSMT0'
).hide();
$(
'#idSMT1'
).hide();
$(
'#idSMT2'
).show();
$(
'#idSMT3'
).hide();
$(
'#idSMT4'
).hide();
}
else
if
(data>=7 && data<=8){
//强
$(
'#idSM1'
).attr(
'class'
,
'pwdChkCon3'
);
$(
'#idSM2'
).attr(
'class'
,
'pwdChkCon3'
);
$(
'#idSM3'
).attr(
'class'
,
'pwdChkCon3'
);
$(
'#idSM4'
).attr(
'class'
,
'pwdChkCon0'
);
$(
'#idSMT0'
).hide();
$(
'#idSMT1'
).hide();
$(
'#idSMT2'
).hide();
$(
'#idSMT3'
).show();
$(
'#idSMT4'
).hide();
}
else
if
(data>=9 && data<=10){
//极好
$(
'#idSM1'
).attr(
'class'
,
'pwdChkCon4'
);
$(
'#idSM2'
).attr(
'class'
,
'pwdChkCon4'
);
$(
'#idSM3'
).attr(
'class'
,
'pwdChkCon4'
);
$(
'#idSM4'
).attr(
'class'
,
'pwdChkCon4'
);
$(
'#idSMT0'
).hide();
$(
'#idSMT1'
).hide();
$(
'#idSMT2'
).hide();
$(
'#idSMT3'
).hide();
$(
'#idSMT4'
).show();
}
});
}
四、css
1
2
3
4
5
6
7
<style>
.pwdChkCon
0
{BORDER-RIGHT:
#bebebe
1px
solid
;BORDER-BOTTOM:
#bebebe
1px
solid
;BACKGROUND-COLOR:
#ebebeb
;TEXT-ALIGN:
center
;}
.pwdChkCon
1
{BORDER-RIGHT:
#bb2b2b
1px
solid
;BORDER-BOTTOM:
#bb2b2b
1px
solid
;BACKGROUND-COLOR:
#ff4545
;TEXT-ALIGN:
center
;}
.pwdChkCon
2
{BORDER-RIGHT:
#e9ae10
1px
solid
;BORDER-BOTTOM:
#e9ae10
1px
solid
;BACKGROUND-COLOR:
#ffd35e
;TEXT-ALIGN:
center
;}
.pwdChkCon
3
{BORDER-RIGHT:
#267a12
1px
solid
;BORDER-BOTTOM:
#267a12
1px
solid
;BACKGROUND-COLOR:
#3abb1c
;TEXT-ALIGN:
center
;}
.pwdChkCon
4
{BORDER-RIGHT:
#267a12
1px
solid
;BORDER-BOTTOM:
#267a12
1px
solid
;BACKGROUND-COLOR:
#3abb1c
;TEXT-ALIGN:
center
;}
</style>
阅读全文
0 0
- php判断密码强度
- php判断密码强度
- php判断密码强度
- JavaScript密码强度判断
- javascript密码强度判断
- js判断密码强度
- IOS密码强度判断
- jQuery判断密码强度
- jQuery判断密码强度
- js判断密码强度
- 密码强度判断,弱中强
- JavaScript判断密码强度
- JS判断密码强度
- jQuery判断密码强度
- 密码强度判断
- 判断密码强度
- 判断密码强度
- javascript密码强度判断
- C/C++中输入多组数据方法
- 使用数据库UNIQUE constraint failed
- Spring MVC与Struts2的区别
- 结合FlexboxLayout实现标签选择功能
- ionic3(一)安装和配置
- php判断密码强度
- js 中处理金额数据 四舍五入数据(,处理和保留小数处理)
- svn插件集成myeclipse2014的两种方式
- Codeforces 834B-The Festive Evening
- java实现点击的图片验证码
- Raspberry Pi 3B I2C连接MPU-6050六轴感测器
- storyboard Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:]
- flume高并发优化——(16)解决offsets变小问题
- webservice之cxf服务端及客户端实现(maven创建web项目)