<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户注册</title>
<script language="javascript">
<!--
function MyForm(){
msg.innerHTML="debug::in function";
var username = document.form1.username.value;
var msg = document.getElementById("msg");
if(username.length==0){
msg.innerHTML="[ 提示:用户名不能为空! ]";
document.form1.username.focus();
return false;
}
var pass = document.form1.password.value;
if(pass.length==0){
msg.innerHTML="[ 提示:密码不能为空! ]";
document.form1.password.focus();
return false;
}
var pass1 = document.form1.password1.value;
if(pass1.length==0){
msg.innerHTML="[ 提示:确认密码不能为空! ]";
document.form1.password1.focus();
return false;
}
if(pass1!=pass){
msg.innerHTML="[ 提示:您两次输入的密码不一致! ]";
document.form1.passwoid.focus();
return false;
}
var mail = document.form1.mail.value;
if(mail.length==0){
msg.innerHTML="[ 提示:E_mail不能为空! ]";
document.form1.mail.focus();
return false;
}
var i = form1.mail.value.indexOf("@");
var j = form1.mail.value.indexOf(".");
if((i<0)||(j<0)||(i-j>0))
{
msg.innerHTML="[ 提示:您输入的E_mail格式不正确,请正确输入! ]";
document.form1.mail.focus();
return false;
}
msg.innerHTML="";
return true;
}
-->
</script>
</head>
<body>
<form method="post" action="" onsubmit="return MyForm()">
<table cellpadding="5">
<tr>
<td colspan="2"><div>用户注册<br /></div></td>
</tr>
<tr>
<td colspan="2" bordercolor=""
bgcolor="">
<font color="red"><span>${error}</span> </font>
</td>
</tr>
<tr>
<td>用户名:</td>
<td><label>
<input type="text" size="20" />
</label>
*(必填)</td>
</tr>
<tr>
<td>用户密码:</td>
<td><label>
<input type="password" size="20" />
</label>
*(必填)</td>
</tr>
<tr>
<td>重复密码:</td>
<td><label>
<input type="password" size="20" />
</label>
*(必填)</td>
</tr>
<tr>
<td>电子邮件:</td>
<td><label>
<input type="text" size="25" />
</label>
*(必填)</td>
</tr>
<tr>
<td>电话:</td>
<td><label>
<input type="text" size="22" />
</label></td>
</tr>
<tr>
<td>QQ:</td>
<td><label>
<input type="text" size="22" />
</label></td>
</tr>
<tr>
<td colspan="2"><label>
<div>
<input type="submit" value="注册" />
<input type="reset" value="重置" />
</div>
</label></td>
</tr>
</table>
</form>
</body>
</html>
提交表单时执行func方法实现代码
内容版权声明:除非注明,否则皆为本站原创文章。