Source code:
Copy codeThe Code is as follows:
<! 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">
<Meta name = "Author" content = "Liu jiangbo">
<Script type = "text/javascript">
Function login (){
Var userName = document. getElementById ("userName"). value;
Var pwd = document. getElementById ("pwd"). value;
Var repwd = document. getElementById ("repwd"). value;
Var address = document. getElementById ("address"). value;
Var matchResult = true;
If (userName = "" | pwd = "" | repwd = "" | address = ""){
Alert ("Please confirm if there are any missing items! ");
MatchResult = false;
} Else if (userName. length <6 | userName. length> 20 ){
Alert ("the username length should be between 6 and 20 characters! ");
MatchResult = false;
} Else if (userName = pwd | userName = repwd ){
Alert ("the password or repeated password cannot be the same as the user name! ");
MatchResult = false;
} Else if (pwd. length <6 | pwd. length> 20 | repwd. length <6 | repwd. length> 20 ){
Alert ("the password or repeated password should be between 6 and 20 characters! ");
MatchResult = false;
} Else if (pwd! = Repwd ){
Alert ("the password is different from the repeated password. Please try again! ");
MatchResult = false;
} Else if (userName. length <6 | userName. length> 20 ){
Alert ("the username length should be between 6 and 20 characters! ");
MatchResult = false;
}
If (matchResult = true ){
Var mailreg =/^ \ w + @ \ w + (\. \ w +) + $ /;
If (! Address. match (mailreg )){
Alert ("Incorrect email format ");
MatchResult = false;
}
}
If (matchResult = true ){
If (userName. charAt (0)> = 0 & userName. charAt (0) <= 9 ){
Alert ("the user name cannot start with a number! ");
MatchResult = false;
}
}
Return matchResult;
}
</Script>
<Title> user registration and verification </title>
</Head>
<Body>
<Center>
<Form name = "loginForm" action = "http://www.ytu.edu.cn" onsubmit = "return login ()" method = "post">
<Table bgcolor = "# 6666FF" width = "300" cellspacing = "0" cellpadding = "0" border = "0" align = "left" valign = "top">
<Tr>
<Td class = "table-title" colspan = "2" align = "center" bgcolor = "# 3366FF"> User Registration </td>
</Tr>
<Tr>
<Td width = "130" height = "28" align = "left"> logon username </td>
<Td> <input id = "userName" name = "userName" type = "text" class = "input"> </td>
</Tr>
<Tr>
<Td width = "80" height = "28" align = "left"> logon password </td>
<Td> <input id = "pwd" name = "pwd" type = "password" class = "input"> </td>
</Tr>
<Tr>
<Td width = "80" height = "28" align = "left"> repeat the password </td>
<Td> <input id = "repwd" name = "repwd" type = "password" class = "input"> </td>
</Tr>
<Tr>
<Td width = "80" height = "28" align = "left"> valid email address </td>
<Td> <input id = "address" name = "address" type = "text" class = "input"> </td>
</Tr>
<Tr>
<! -- <Td width = "10" height = "28" align = "left"> </td> -->
<Td colspan = "2">
<Input type = "submit" value = "login">
<Input type = "button" value = "cancel" onClick = "reset ()"> </td>
</Tr>
</Table>
</Form>
</Center>
</Body>
</Html>
Effect implementation: