User Registration common JavaScript code _ form Effects

Source: Internet
Author: User
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>
&LT;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>
&LT;TD width= "50%" align= "right" height= "" ><font face= "Arial, Helvetica, Sans-serif" > Please enter the username to be registered: </font ></td>
&LT;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>
&LT;TD width= "50%" align= "right" height= ">" Enter your password:</td>
&LT;TD width= "50%" align= "left" height= "> <input" type= "password" name= "UserPassword" ></td>
</tr>
<tr>
&LT;TD width= "50%" align= "right" height= ">" Please enter confirmation password:</td>
&LT;TD width= "50%" align= "left" height= "> <input" type= "password" name= "Cuserpassword" ></td>
</tr>
<tr>
&LT;TD width= "50%" align= "right" height= ">" Please enter nickname:</td>
&LT;TD width= "50%" align= "left" height= "> <input type=" text "name=" nickname "></td>
</tr>
<tr>
&LT;TD width= "50%" align= "right" height= "> Please select Gender:</td>
&LT;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>
&LT;TD width= "50%" align= "right" height= ">" Enter your email address:</td>
&LT;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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.