<%@ page language="java" contentType="text/html; charset=GB2312"%>
<html>
<head>
<title>注册用户</title>
<script type="text/javascript">
var http_request = false;
function createXMLHttpRequest() {
http_request = false;
if(window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType("text/xml");
}
}
else if (window.ActiveXObject) {
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
window.alert("不能创建XMLHttpRequest 对象实例.");
return false;
}
}
function xmlhttpRequestEmail(infobox){
if(checkEmail(infobox)){
createXMLHttpRequest();
var url = "http://localhost:8081/portal/showUser.do?email=" + document.reguser.email.value;
http_request.open("POST", url, true);
http_request.onreadystatechange = callbackEmail;
http_request.send(null);
return true;
}
return false;
}
function checkEmail(infobox){
var email = document.reguser.email.value;
if(email == ""){
formMsg(infobox,"请输入email地址");
return false;
}
var emailtest =/^/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*$/;
if(!emailtest.test(email)){
formMsg(infobox,"输入的email地址不正确");
return false;
}
return true;
}
function formMsg(infobox,errormsg){
document.getElementById(infobox).innerHTML = errormsg;
document.getElementById(infobox).className = "style3";
}
function hideMsg(strtype){
document.getElementById(strtype).style.display="none";
}
function callbackEmail() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var res = http_request.responseText;
if(res=="0"){
document.getElementById("emaildiv").innerHTML= "恭喜您,电子邮件可以注册";
document.getElementById("emaildiv").className = "style3"
}else if(res=="1"){
document.getElementById("emaildiv").innerHTML= "电子邮件已经注册过,请使用另一个邮箱";
document.getElementById("emaildiv").className = "style3"
}
}
}
}
</script>
</head>
<body>
<center>
<form action="registerUser.do" name="reguser" method="post" οnsubmit="return validate()">
<table width="90%" border="0" cellspacing="1" cellpadding="3" align="center" class="FORM">
<thead>
<tr>
<td class="dgrtitle" colspan="2">注册用户</td>
</tr>
</thead>
<tbody>
<tr>
<td width="20%"><span class="required">*</span> 电子邮件:</td>
<td width="20%">
<input type="text" name="email" size="30" maxlength="30" οnblur="xmlhttpRequestEmail('emaildiv');" Class="inputnotnull" />
</td><td width="20%"><div id="emaildiv"></div></td>
</tr>
</tbody>
</table>
</form>
</center>
<br>
</body>
</html>