jsp简单等录

来源:互联网 发布:淘宝上怎么卖话费充值 编辑:程序博客网 时间:2024/06/11 07:37

index.jsp

 

<%@ 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 HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'index.jsp' starting page</title>
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 
  </head>
 
 
  <script type="text/javascript" src="re.js">
</script>
  <body>
    <form action="" name="form" method="post">
     <table width="70%" class="mars" cellspacing="1" cellpadding="0" width="100%" border="0">
      <!-- 用户名 -->
      
      <tr>
          <td class="item" width="41%">
           <div algin="right">用户名:</div>
          </td>
          <td width="7%"></td>
          <td width="52%">
               <input type="text" name="username" id="username">
               &nbsp;&nbsp;
               <font color="red">*</font>
               <div id="usernameCheckDiv" class="warning">
               </div>
          </td>
      </tr>
      
      
      <!--密码 -->
      <tr>
               <td class="item">
                     <div algin="right">密码:</div>
               </td>
               <td width="7%"></td>
               <td >
               <input type="password" name="password" id="password">
               &nbsp;&nbsp;
               <font color="red">*</font>
          </td>
      </tr>
      
      <!--确认密码 -->
      <tr>
               <td class="item">
                     <div algin="right">确认密码:</div>
               </td>
               <td width="7%"></td>
               <td >
               <input type="password" name="password2" id="password2">
               &nbsp;&nbsp;
               <font color="red">*</font>
          </td>
      </tr>
      
      
      
      <!--公司名称: -->
      <tr>
               <td class="item">
                     <div algin="right">公司名称:</div>
               </td>
               <td width="7%"></td>
               <td >
               <input type="text" name="companyname" id="companyname">
               &nbsp;&nbsp;
               <font color="red">*</font>
          </td>
      </tr>
      
      
      
      
      <!--公司地址: -->
      <tr>
               <td class="item">
                     <div algin="right">公司地址:</div>
               </td>
               <td width="7%"></td>
               <td >
               <input type="text" name="companyaddress" id="companyaddress">
               &nbsp;&nbsp;
               <font color="red">*</font>
          </td>
      </tr>
      
    
         <!--国家: -->
      <tr>
               <td class="item">
                     <div algin="right">国家:</div>
               </td>
               <td width="7%"></td>
               <td >
               <input type="text" name="country" id="country">
               &nbsp;&nbsp;
               <font color="red">*</font>
          </td>
      </tr>
      
      <!--城市: -->
      <tr>
               <td class="item">
                     <div algin="right">城市:</div>
               </td>
               <td width="7%"></td>
               <td >
               <input type="text" name="city" id="city">
               &nbsp;&nbsp;
               <font color="red">*</font>
          </td>
      </tr>
      
      
      
      <!--工作: -->
      <tr>
               <td class="item">
                     <div algin="right">工作:</div>
               </td>
               <td width="7%"></td>
               <td >
               <input type="text" name="job" id="job">
               &nbsp;&nbsp;
               <font color="red">*</font>
          </td>
      </tr>
    
    
      
      <!--电话: -->
      <tr>
               <td class="item">
                     <div algin="right">电话:</div>
               </td>
               <td width="7%"></td>
               <td >
               <input type="text" name="tel" id="tel">
               &nbsp;&nbsp;
               <font color="red">*</font>
          </td>
      </tr>
      
      
      <!--zip: -->
      <tr>
               <td class="item">
                     <div algin="right">zip:</div>
               </td>
               <td width="7%"></td>
               <td >
               <input type="text" name="zip" id="zip">
               &nbsp;&nbsp;
               <font color="red">*</font>
          </td>
      </tr>
      
      
       <!--Email: -->
      <tr>
               <td class="item">
                     <div algin="right">Email:</div>
               </td>
               <td width="7%"></td>
               <td >
               <input type="text" name="Email" id="Email">
               &nbsp;&nbsp;
               <font color="red">*</font>
          </td>
      </tr>
      
      <tr>
      
      
      <td colspan="3" algin="center">
      
          <input type="submit" value="注册" onclick="return check();"/>
          <input type="reset" value="取消"/>
      </td>
      </tr>
      
     </table>
    </form>
  </body>
</html>

 

 

re.js

 

 

  
  
  function check(){
 
   if(form.username.value==""){
  alert("用户名不能为空:");
  form.username.focus();
  return false;
  }
  if(form.password.value==""){
  alert("请输入密码:");
  form.password.focus();
  return false;
  }
 
   
    if(form.password2.value==""){
  alert("请再次输入密码:");
  form.password2.focus();
  return false;
  }
 
  if(form.password.value!=form.password2.value){
  alert("两次输入的密码不一致");
  form.password2.focus();
  return false;
  }
  if(form.email.value==""){
  alert("请输入邮件");
  form.eamil.focus();
  return false;
  }
  var regm=/^[z-zA-Z0-9_-]+@[z-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
 
  if(form.email.value!="" && !form.eamil.value.match(regm)){
  alert("邮件的格式不对,检查 后重新输入");
  form.email.focus();
  return false;
  }
  }
 

 

 

 

 


 

0 0
原创粉丝点击