<%@ page language="java" import="java.util.*" contentType="text/html; charset=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 'index.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" href="css/style.css"/>
<title>
用户注册
</title>
</head>
<body bgcolor="#e3e3e3">
<div class="head">
<center><span>网上书店</span></center>
</div>
<form name="Reg" action="servlet/RegisterSerlet" method="post">
<div class="form_row">
<table class="contact">
<tr>
<td>登录名: <input type="text" name="logname"> <span style="color:red;">*</span></td>
</tr>
<tr>
<td>真实姓名: <input type="text" name="realname"> <span style="color:red;">*</span></td>
</tr>
<tr>
<td>密码: <input type="password" name="password" class="contact"> <span style="color:red;">*</span> </td></tr>
<tr>
<td>email: <input type="text" name="email"> <span style="color:red;">*</span></td>
</tr>
<tr>
<td>地址: <input type="text" name="address" class="contact"> <span style="color:red;">*</span></td></tr>
<tr>
<td>电话: <input type="text" name="phone"> <span style="color:red;">*</span></td>
</tr>
<tr>
<td>密码提示问题:<input type="text" name="problem" class="contact"> <span style="color:red;">*</span></td></tr>
<tr>
<td>密码回答问题:<input type="text" name="answer"> <span style="color:red;">*</span></td>
</tr>
<tr>
<td>省份:
<select name="province">
<option>河北省</option>
<option>贵州省</option>
<option>湖北省</option>
<option>宁夏</option>
</select>
<span style="color:red;">*</span>
</td>
</tr>
<tr>
<td>企业用户简介:<br>
<textarea name="selfintro" id="text" rows="5" cols="70" placeholder="请输入企业用户内容";
style="color: dimgrey; font-size: 16px; autofocus:true;"
onfocus="textIN('text')"></textarea>
<span style="color:red;">*</span></td>
</tr>
<tr><td>
<select name="type">
<option >1</option>
<option>2</option>
</select></td></tr>
<tr>
<td><a href="login.jsp">返回登录</a></td></tr>
<tr>
<td ><input type="submit" value="注册" name="submit"></td>
</tr>
</table>
</div>
</form>
<script>
function textIN(id){
var text = document.getElementById(id);
text.style.color = "gray";
text.style.fontFamily = "宋体";
text.style.fontSize = 18;
}
</script>
<script>
var usernameRegex = /^\w{3,15}$/;
var passwordRegex = /^\w{6,12}$/;
var emailRegex = /^\w+@\w+(\.\w+)+$/;
function validateForm(){
var flag = true;
var usernameNode = byId("username");
var username = usernameNode.value;
if(!usernameRegex.test(username)){
byId("username_span").style.color = "red";
flag = false;
}
var passwordNode = byId("password1");
var password = passwordNode.value;
if(!passwordRegex.test(password)){
byId("password1_span").style.color = "red";
flag = false;
}
var emailNode = byId("email");
var email = emailNode.value;
if(!emailRegex.test(email)){
byId("email_span").style.color = "red";
flag = false;
}
return flag;
}
function byId(id){
return document.getElementById(id);
}
function checkUsername(node){
var username = node.value;
if(!usernameRegex.test(username)){
byId("username_span").style.color = "red";
}else{
byId("username_span").style.color = "green";
}
}
function checkPassword(node){
var password1 = node.value;
if (!passwordRegex.test(password)) {
byId("password1_span").style.color = "red";
}
else {
byId("password1_span").style.color = "green";
}
}
function checkRePassword(node){
var rePassword = node.value;
var password = byId("password2").value;
if(!password==rePassword){
byId("rePassword2_span").style.color = "red";
}else if(!passwordRegex.test(rePassword)){
byId("rePassword2_span").style.color = "red";
}else{
byId("rePassword2_span").style.color = "green";
}
}
function checkEmail(node){
var email = node.value;
if(!emailRegex.test(email)){
byId("email_span").style.color = "red";
}else{
byId("email_span").style.color = "green";
}
}
</script>
</body>
</html>