<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
>
<
head
>
<
title
></
title
>
<
script
language
=
"javascript"
type
=
"text/javascript"
>
function checkstr(str)
{
if (str >= 48 && str <= 57)//数字
{
return 1;
}
else if (str >= 65 && str <= 90)//大写字母
{
return 2;
}
else if (str >= 97 && str <= 122)//小写字母
{
return 3;
}
else//特殊字符
{
return 4;
}
}
function checkl(string)
{
n = false;
s = false;
t = false;
l_num = 0;
if(string.length <= 0){
l_num = 0;
}
if (string.length <
6
&& string.length > 0)
{
l_num = 1;
}
else
{
for (i = 0; i <
string.length
; i++)
{
asc
=
checkstr
(string.charCodeAt(i));
if (asc == 1 && n == false)
{ l_num += 1;
n
=
true
; }
if ((asc == 2 || asc == 3) && s == false)
{ l_num += 1;
s
=
true
; }
if (asc == 4 && t == false)
{ l_num += 1;
t
=
true
; }
}
}
return l_num;
}
function checklevel(psw)
{
color
=
"#ededed"
;
color_l
=
"#ff0000"
;
color_m
=
"#ff9900"
;
color_h
=
"#33cc00"
;
if (psw == null || psw == '')
{
lcor
=
color
;
mcor
=
color
;
hcor
=
color
;
}
else
{
thelev
=
checkl
(psw)
switch (thelev)
{
case 0:
lcor
=
hcor
=
mcor
=
color
;
break;
case 1:
lcor
=
color_l
;
hcor
=
mcor
= color;
break;
case 2:
mcor
=
lcor
= color_m;
hcor
=
color
;
break;
case 3:
hcor
=
mcor
=
lcor
=
color_h
;
break;
default:
lcor
=
mcor
=
hcor
=
color
;
}
}
document.getElementById("strength_L")
.style.background
=
lcor
;
document.getElementById("strength_M")
.style.background
=
mcor
;
document.getElementById("strength_H")
.style.background
=
hcor
;
}
</script>
</
head
>
<
body
>
<
form
>
密码:
<
input
type
=
"password"
size
=
"10"
onkeyup
=
"checklevel(this.value)"
onchange
=
"checklevel(this.value)"
/>
<
br
/><
br
/><
br
/>
强度:
<
table
width
=
"210"
cellspacing
=
"1"
cellpadding
=
"0"
bordercolor
=
"#cccccc"
height
=
"9"
>
<
tr
align
=
"center"
bgcolor
=
"#eeeeee"
>
<
td
width
=
"33%"
height
=
"5"
id
=
"strength_L"
>
</
td
>
<
td
width
=
"33%"
id
=
"strength_M"
>
</
td
>
<
td
width
=
"33%"
id
=
"strength_H"
>
</
td
>
</
tr
>
</
table
>
</
form
>
</
body
>
</
html
>