密码强弱显示两种方式

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'Md.jsp' starting page</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">   
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
#Register .Pstyle6 .textstyle1 {
padding:8px 22px;
margin:0 1px;
border-top:5px solid #CCCCCC;
}
#Register .Pstyle6 .textstyle2 {
padding:8px 22px;
margin:0 1px;
    border-top:5px solid #009900;
}
</style>
<script>
    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<6)
{
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 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 name="frm">
密码:
<input type=password size=10 onKeyUp=checklevel(this.value) onBlur=checklevel(this.value) >
<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>

你可能感兴趣的:(JavaScript,java,html,jsp)