Copy Code code as follows:
<%@ page contenttype= "text/html; charset=gb2312 "Language=" Java%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> User Registration </title>
<script language= "JavaScript" >
function IsDigit (Ccheck)
{
Return (' 0 ' <=ccheck) && (ccheck<= ' 9 '));
}
function Isalpha (Ccheck)
{
Return ((' a ' <=ccheck) && (ccheck<= ' z ') | | ((' A ' <=ccheck) && (ccheck<= ' Z '))
}
function IsValid ()
{
var strUserName = Reg. Username.value;
for (nindex=0; nindex<strusername.length; nindex++)
{
Ccheck = Strusername.charat (nindex);
if (!) ( IsDigit (Ccheck) | | Isalpha (Ccheck))
{
return false;
}
}
return true;
}
function Chkemail (str)
{
Return Str.search (/[\w\-]{1,}@[\w\-]{1,}\.[ \w\-]{1,}/) ==0?true:false
}
function Docheck ()
{
if (Reg. username.value== "")
{
Alert ("Please fill in User name");
return false;
}
else if (! IsValid ())
{
Alert ("User name can only use letters and numbers");
return false;
}
else if (Reg. userpassword.value== "")
{
Alert ("Please fill in the password");
return false;
}
else if (Reg. Userpassword.value!= Reg. Cuserpassword.value)
{
Alert ("Two times password inconsistency");
return false;
}
else if (Reg. Nickname.value = "")
{
Alert ("Please fill in the nickname");
return false;
}
else if (Reg. Email.value = "")
{
Alert ("Please fill in the mailbox");
return false;
}
else if (!chkemail (REG). Email.value))
{
Alert ("Please fill in a valid email address");
return false;
}
Else
{
return true;
}
}
</script>
<style type=text/css>
TD, Th {
Font-family:arial, Helvetica, Sans-serif;
font-size:14px;
line-height:24px;
Color: #333333;
}
</STYLE>
<body>
<H1 align= "center" > User Registration <div align= "center" >
<form name= "Reg" action= "user_add.jsp" method= "post" target= "_self" onsubmit= "return Docheck ()" >
<table width= "90%" border= "0" >
<tr>
<TD width= "50%" align= "right" height= "" ><font face= "Arial, Helvetica, Sans-serif" > Please enter the username to be registered: </font ></td>
<TD width= "50%" align= "left" height= ">"
<input type= "text" name= "UserName" >
<br>
<font color= "Red" > username can only be made up of letters and numbers </font>
</td>
</tr>
<tr>
<TD width= "50%" align= "right" height= ">" Enter your password:</td>
<TD width= "50%" align= "left" height= "> <input" type= "password" name= "UserPassword" ></td>
</tr>
<tr>
<TD width= "50%" align= "right" height= ">" Please enter confirmation password:</td>
<TD width= "50%" align= "left" height= "> <input" type= "password" name= "Cuserpassword" ></td>
</tr>
<tr>
<TD width= "50%" align= "right" height= ">" Please enter nickname:</td>
<TD width= "50%" align= "left" height= "> <input type=" text "name=" nickname "></td>
</tr>
<tr>
<TD width= "50%" align= "right" height= "> Please select Gender:</td>
<TD width= "50%" align= "left" height= "> <input type=" Radio "name=" Sex "value=" 0 "checked> male <input type= "Radio" name= "Sex" value= "1" > </td>
</tr>
<tr>
<TD width= "50%" align= "right" height= ">" Enter your email address:</td>
<TD width= "50%" align= "left" height= "> <input type=" text "name=" Email "></td>
</tr>
</table>
<p>
<input type= "Submit" Name= "sub" value= "registered" >
<input type= "Reset" name= "res" value= "re-fill" >
</p>
</form>
</div>
</body>