<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> registered member </title>
<Style type = "text/css">
. Table {
Border-collapse: collapse;
Font-size: 12px;
}
. Input {
Width: 200px;
Height: 22px;
}
. Stats1 {
Color: # aaa;
}
. Stats2 {
Color: #000;
}
. Stats3 {
Color: red;
}
. Stats4 {
Color: green;
}
</Style>
</Head>
<Body>
<Form action = "index. php" method = "post" onSubmit = "return regCheck ('click')">
<Table border = "0" align = "center" width = "500" class = "table">
<Tr>
<Td width = "80" height = "25" align = "right"> User Name: </td> <input type = "text" name = "username" value = "" class = "input"/> <span class = "stats1"> </ span> </td>
</Tr>
<Tr>
<Td width = "80" height = "25" align = "right"> password: </td> <input type = "password" name = "password" value = "" class = "input"/> <span class = "stats1"> </ span> </td>
</Tr>
<Tr>
<Td width = "80" height = "25" align = "right"> confirm the password: </td> <input type = "password" name = "repass" value = "" class = "input"/> <span class = "stats1"> </ span> </td>
</Tr>
<Tr>
<Td width = "80" height = "25" align = "right"> Email: </td> <input type = "text" name = "email" value = "" class = "input"/> <span class = "stats1"> </ span> </td>
</Tr>
<Tr>
<Td height = "30"> </td> <td align = "left"> <input type = "submit" name = "send" value = "submit"/> <input type = "reset" value = "reset"/> </td>
</Tr>
</Table>
</Form>
</Body>
</Html>
<Script language = "javascript">
// Locate the SPAN tag after input
Function gspan (cobj ){
While (true ){
If (cobj. nextSibling. nodeName! = "SPAN ")
Cobj = cobj. nextSibling;
Else
Return cobj. nextSibling;
}
}
Function check (obj, info, fun, click ){
Var sp = gspan (obj );
Obj. onfocus = function (){
Sp. innerHTML = info;
Sp. className = "stats2 ";
}
Obj. onblur = function (){
If (fun (this. value )){
Sp. innerHTML = "correct input √ ";
Sp. className = "stats4 ";
} Else {
Sp. innerHTML = info;
Sp. className = "stats3 ";
}
}
If (click = "click ")
Obj. onblur ();
}
// Automatic call after page loading
Onload = regCheck
Function regCheck (click ){
Var stat = true;
Var username = document. getElementsByName ("username") [0];
Var password = document. getElementsByName ("password") [0];
Var repass = document. getElementsByName ("repass") [0];
Var email = document. getElementsByName ("email") [0];
Var other = document. getElementsByName ("other") [0];
// Verify the user name
Check (username, "username is a 4-20-digit English letter or number! ", Function (val ){
If (val. match (/^ \ S + $/) & val. length> = 4 & val. length <= 20 ){
Return true;
} Else {
Stat = false;
Return false;
}
}, Click );
// Verify the password
Check (password, "the user password must be between 6 and 20 characters! ", Function (val ){
If (val. match (/^ \ S + $/) & val. length> = 6 & val. length <= 20 ){
Return true;
} Else {
Stat = false;
Return false;
}
}, Click );
// Verify the password
Check (repass, "Make sure the password is the same as above! ", Function (val ){
If (val. match (/^ \ S + $/) & val. length> = 6 & val. length <= 20 & val = password. value ){
Return true;
} Else {
Stat = false;
Return false;
}
}, Click)
// Verify Email
Check (email, "enter an email in the correct format! ", Function (val ){
If (val. match (/\ w + @ \ w + \. \ w /)){
Return true;
} Else {
Stat = false;
Return false;
}
}, Click)
Return stat;
}
</Script>
From Lee.'s column