<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>新用户注册</title>
<script language="javascript">
var xmlHttp = false;
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
xmlHttp = new XMLHttpRequest();
}
function check()
{
var name = document.getElementById("yhm").value;
var pwd = document.getElementById("pwd").value;
var url = "checkRegist.jsp?info=" + name + "&info2=" + pwd ;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange = getResult;
xmlHttp.send();
}
function getResult()
{
if(xmlHttp.readyState == 4)
{
var result = xmlHttp.responseText;
document.getElementById("msg").innerHTML = result.substring(0,result.indexOf("&"));
if(result.indexOf("可用")!=-1)
{
document.getElementById("msg2").innerHTML = result.substr(result.indexOf("&")+1);
}
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<table width="540" border="0" align="center">
<tr>
<td width="60" align="right">用户名: </td>
<td width="173"><input type="text" name="yhm" id="yhm" onBlur="check();" style="width:200px;height:20px"></td>
<td width="285"><div id="msg" style="background-color:#999999"></div></td>
</tr>
<tr>
<td align="right">密 码:</td>
<td><input type="password" name="pwd" id="pwd" style="width:200px;height:20px" onBlur="check();"></td>
<td><div id="msg2" style="background-color:#999999"></div></td>
</tr>
<tr>
<td colspan="3"><input type="submit" name="button" id="button" value="提交"></td>
</tr>
</table>
</form>
</body>
</html>
---------------------------------------------------------------------
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%
String info=request.getParameter("info");
if(info!=null && info.trim().length()>0)
{
if(info.equals("admin"))
{
String s="<font color='#ff0000'>用户名" + info + "已经存在!</font>&";
out.println(s);
}
else
{
out.print("<font color='#008800'>恭喜您!用户名可用!</font>&");
}
}
else
{
out.println("<font color='#ffff00'>用户名不能为空</font>&");
}
String info2=request.getParameter("info2");
if(info2!=null && info2.trim().length()>0)
{
if(info2.length()<6 || info2.length()>12)
{
out.println("<font color='#ff0000'>密码长度必须在6~12位之间</font>");
}
else
{
if(info2.length()>=6 && info2.length()<=8)
{
out.println("<font color='#ff0000'>密码的安全性低</font>");
}
else
{
out.println("<font color='#008800'>密码的安全性高</font>");
}
}
}
else
{
out.println("<font color='#ffff00'>密码不能为空</font>");
}
%>