javascript基础教程

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Regist</title>
<link rel="stylesheet" href="css/RoundedCorner.css" type="text/css" media="all">

<style type="text/css">
#main {
	height: 600px;
	width: 800px;
	margin: auto;
}
#line {
	color: #F60;
	height: 1px;
	width: 90%;
	background-color: #F63;
	margin: auto;
}
nav,div,dl,dt,dd,ul,ol,li,pre,form,fieldset,input,textarea,blockquote{padding:0; margin:0;}
li{list-style-type:none;}
/*main nav*/
#nav{
	background:url('images/nav_li_bg.gif') repeat-x top;
	height:37px;
	position:relative;
	width:988px;
	margin:20px auto;
	font-size: 12px;
}
#nav .l{ background:url('images/nav_li_left.gif') no-repeat top; height:37px;width:78px; float:left}
#nav .r{width:82px;background:url('images/nav_li_right.gif') no-repeat right top;height:37px;float:left;}
#nav li { float:left;}
#nav li .v a{ width:138px;height:37px; line-height:32px; display:block; color:#FFF;float:left;font-weight:bold;text-decoration:none;text-align:center;}
#nav li .v a:hover,#nav li .v .sele{
	width:138px;
	background:url('images/nav_li_hover.gif') no-repeat top;
	color:#fff;
	height:37px;
	line-height:37px;
	color:#d11515;
	font-size: 12px;
}
</style>
<script type="text/javascript">
function check()
{
	var username=document.getElementById("username").value;
	var password=document.getElementById("password").value;
	var repassword=document.getElementById("repassword").value;
	var email=document.getElementById("email").value; 
	var apos=email.indexOf("@");
	var dotpos=email.lastIndexOf(".");
	 var phoneNum=document.getElementById("phonenum").value;
     var qqName=document.getElementById("qqnum").value;
     var Blog=document.getElementById("blog").value;
     var School=document.getElementById("school").value;
     var checkOK = "0123456789-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
     var checkStr = username;
     var allValid = true;
     var decPoints = 0;
	if(username.length<1)
		{
		 alert("用户名不能为空!");
		 return false;
		}
	if(username.length>20||username.length<3){
		alert("用户名必须在3~20个字符之间!");
		return false;
	}
	if(password.length<1)
		{
		alert("密码不能为空!");
		return false;
		}
	if(password.length>20||password.length<3)
		{
		alert("密码必须在3~20个字符之间!");
		return false;
		}
	if(password!=repassword)
		{
		 alert("两次输入的密码不相符!");
		 return false;
		}
	if(email.length<1)
		{
		alert("email必填内容!");
		return false;
		}
	if(email.match("@")==null||apos<1||dotpos-apos<2)
	{
		alert("不是有效的email地址!");
		return false;
	}
	for (i = 0; i < checkStr.length; i++)
     {
      ch = checkStr.charAt(i);
      for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
      break;
       if (j == checkOK.length)
       {
        allValid = false;
        alert("用户名只能是英文和数字的组合");
        windows.location="www.baidu.com";
        break;
       }
      }
      if(allValid){
         alert("跳转到servlet");
         window.location.href="../../regist2?userName="+username+"&passWord="+password+"&Email="+email+"&phoneNum="+phoneNum+"&qqName="+qqName+"&Blog="+Blog+"&School="+School;
         alert("跳转到servlet失败");
      }
    
	return true;
	}
</script>
</head>

<body>
<DIV id=nav>

<DIV class=l></DIV>
<UL class=c>
  <LI><SPAN class=v><A href="http://www.duice.net" target="_blank">首页</A></SPAN> 
  <LI><SPAN class=v><A href="#">购物</A></SPAN> 
  <LI><SPAN class=v><A href="#">日志</A></SPAN> 
  <LI><SPAN class=v><A href="#">电子商务</A></SPAN> 
  <LI><SPAN class=v><A href="#">网络营销</A></SPAN> 
  <LI><SPAN class=v><A href="#">关于我们</A></SPAN> 
  </UL>
 <DIV class=r></DIV>
</DIV>
</div>
<br>
<br>
<div id="main">
<div id="xsnazzy">
<b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
<div class="xboxcontent">
  <p><br>
    <font size="+2" color="#FF6610"><b>   填写会员信息</b></font>
  <div id="line"> 
  </div>
  </p>
  <form  onsubmit="return check()" action="" method="post">
  <table width="527" height="52" id="RegistTable">
    <td width="139"><div align="right"><font color="#FF0000">*</font>用户名:</div></td><td width="376"><input name="userName" value="" id="username"  size="40" type="text" maxlength="16" onblur="AjaxSubmit();" onfocus="Submit()"/><div id="Ajax"></div><br></td><tr>
      <td><div align="right"></div></td><td><font size="-3">( 5-20位字母、数字或下划线组合,首字符必须为字母。)</font><br><br></td></tr>
<tr>
  <td><div align="right"><font color="#FF0000">*</font>密码:</div></td><td><input name="passWord" id="password" value="" type="password" size="40" maxlength="16"/><br></td></tr>
    <td><div align="right"></div></td>
<td><font size="-3">( 为了您的帐户安全,强烈建议您的密码使用字符+数字等多种不同类型的组合,并且密码长度大于5位。)</font><br><br></td></tr>
    <td><div align="right"><font color="#FF0000">*</font>在此输入密码:</div></td><td><input name="repassWord" id="repassword" value="" type="password" size="40" maxlength="16"/><br></td>
<tr>
  <td><div align="right"></div></td><td><font size="-3">( 确保密码输入正确。)</font><br><br></td></tr>
  <td><div align="right"><font color="#FF0000">*</font> E-mail:</div></td><td><input name="Email" value="" id="email"  size="40" type="text"/><br></td><tr>
    <td><div align="right"></div></td><td><font size="-3">( 请填写正确的邮箱地址!)</font><br><br></td><tr></tr>
  <td><div align="right"><font color="#FF0000">*</font>注册条款:<br>
        <br>
  </div></td><td><input name="TermsofService" id="terms_of_service" type="checkbox" /> 我已仔细阅读并接受<a href="#">IU校园报注册条款</a><br><br></td><tr></table>
  <br><font size="+2" color="#FF6610"><b>    选填信息</b></font><br><br>
  <div id="line2"> 
  </div>
  <br>
  <table width="523">
  <td><div align="right">手机号 : <br><br>
  </div></td><td><input id="phonenum" name="phoneNum" size="40" type="text"/><br><br></td><tr>
  <td><div align="right">qq号 :<br><br> </div></td><td><input id="qqnum" name="qqName" size="40" type="text"/><br><br></td><tr>
  <td><div align="right">博客(微博):<br><br></div></td><td><input id="blog" name="Blog" size="40" type="text"/><br><br></td><tr>
  <td><div align="right">公司(学校) :<br><br></div></td><td><input id="school" name="School" type="text" size="40"/><br><br></td><tr>
  <td> </td><td><input id="submit1" name="Submit" type="submit" value="提交"/></td>
  </table>
  
  <br>
<br>
</form>
</div>
<b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b>
</div>
<div id="Statement">
<table id="statement">
<td>公司简介</td>
<td>|</td>
<td>招贤纳士</td>
<td>|</td>
<td>广告服务</td>
<td>|</td>
<td>联系方式</td>
<td>|</td>
<td>版权声明</td>
<td>|</td>
<td>法律顾问</td>
<td>|</td>
<td>问题报告</td>
<td>|</td>
</table>

</div>
</div>
</body>
</html>

你可能感兴趣的:(javascript基础教程)