Copy codeThe Code is 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">
<Html>
<Head>
<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 ("Enter the user name ");
Return false;
}
Else if (! IsValid ())
{
Alert ("the user name can only contain letters and numbers ");
Return false;
}
Else if (reg. UserPassword. value = "")
{
Alert ("enter the password ");
Return false;
}
Else if (reg. UserPassword. value! = Reg. CUserPassword. value)
{
Alert ("inconsistent passwords ");
Return false;
}
Else if (reg. NickName. value = "")
{
Alert ("Enter your nickname ");
Return false;
}
Else if (reg. Email. value = "")
{
Alert ("Enter your email address ");
Return false;
}
Else if (! ChkEmail (reg. Email. value ))
{
Alert ("Please enter 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>
</Head>
<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 = "25"> <font face = "Arial, Helvetica, sans-serif"> enter the user name to register: </font> </td>
& Lt; td width = "50%" align = "left" height = "25" & gt;
<Input type = "text" name = "UserName">
<Br>
<Font color = "red"> a user name can only consist of letters and numbers </font>
</Td>
</Tr>
<Tr>
<Td width = "50%" align = "right" height = "25"> enter the password: </td>
<Td width = "50%" align = "left" height = "25"> <input type = "password" name = "UserPassword"> </td>
</Tr>
<Tr>
<Td width = "50%" align = "right" height = "25"> enter the password: </td>
<Td width = "50%" align = "left" height = "25"> <input type = "password" name = "CUserPassword"> </td>
</Tr>
<Tr>
<Td width = "50%" align = "right" height = "25"> enter the nickname: </td>
<Td width = "50%" align = "left" height = "25"> <input type = "text" name = "NickName"> </td>
</Tr>
<Tr>
<Td width = "50%" align = "right" height = "25"> select gender: </td>
<Td width = "50%" align = "left" height = "25"> <input type = "radio" name = "Sex" value = "0" checked> male <input type = "radio" name = "Sex" value = "1"> female </td>
</Tr>
<Tr>
<Td width = "50%" align = "right" height = "25"> enter the Email address: </td>
<Td width = "50%" align = "left" height = "25"> <input type = "text" name = "Email"> </td>
</Tr>
</Table>
<P>
<Input type = "submit" name = "sub" value = "register">
<Input type = "reset" name = "res" value = "Refill">
</P>
</Form>
</Div>
</Body>
</Html>