<!-- 用户注册页面 -->
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%><!-- Overrides the name of the character encoding used in the body of this request. -->
<% request.setCharacterEncoding("utf-8"); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language = "javascript">
const SUP = 15; //用户名与密码的上界
const INF = 2; //用户名与密码的下界
//比较密码与确认密码框是否相同
function passwordcof(text1, text2)
{
return (text1 == text2);
}//检查文本框是否为空
function check_empty(text)
{
return ((text.length > INF) && (text.length < SUP));
}//检查邮件格式是否正确
function check_email(address)
{
//邮件的正则表达式
var emailExp = /^[\w-_\.]+@([\w-]+\.)+[\w-]+$/; //test函数检验输入的邮件地址是否符合正则表达式
if(emailExp.test(address))
return true;
else
{
alert("Email输入有误");
return false;
}
}function validate_form()
{
validity = true;
if(!check_empty(document.regForm.username.value))
{
validity = false;
alert('对不起!名字长度必须是(2--15)位!');
}
else if(document.regForm.password.value.length == 0)
{
validity = false;
alert('对不起!请输入密码');
}
else if(document.regForm.passwordConfirm.value.length == 0)
{
validity = false;
alert('对不起!请确认密码');
}
else if(!passwordcof(document.regForm.password.value, document.regForm.passwordConfirm.value))
{
validity = false;
alert('对不起!两次输入的密码不一样');
}
else if(!check_email(document.regForm.useremail.value))
{
validity = false;
alert('对不起!email地址不正确,请填入正确的email地址');
}
return validity;
}</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>注册</title></head>
<body bgcolor = "EFEFEF">
<form name = "regForm" method = "post" action = "registerCof.jsp" onSubmit = "return validate_form()">
<br><br>
<table align = center>
<!-- 填写账号 -->
<tr>
<td width = "20%" height = "26">申请账号:</td>
<td width = "80%" height = "26">
<input type = "text" name = "username">[长度只能是2-15之间长度的数字、字母或下划线]
</td>
</tr>
<!-- 填写密码 -->
<tr>
<td width = "20%" height = "26">密码:</td>
<td width = "80%" height = "26">
<input type = "password" name = "password">[长度只能是2-15之间长度的数字与字母]
</td>
</tr>
<!-- 确认密码 -->
<tr>
<td width = "20%" height = "26">确认密码:</td>
<td width = "80%" height = "26">
<input type = "password" name = "passwordConfirm">[必须与密码完全相同]
</td>
</tr>
<!-- 填写邮箱 -->
<tr>
<td width = "20%" height = "26">email:</td>
<td width = "80%" height = "26">
<input type = "text" name = "useremail">[样式:[email protected]]
</td>
</tr>
<!-- 填写邮件 -->
<tr>
<td width = "20%" height = "26">&nbsp;</td>
<td width = "80%" height = "26">
<input type = "submit" name = "submit" value = "提交">
<input type = "reset" name = "reset" value = "重置">
</td>
</tr>
</table>
</form>
</body>
</html>