<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <script type="text/javascript"> function Check() { var password = document.myform.password.value; var passwordok = document.myform.passwordok.value; var user = document.myform.user.value; var user1 = /^[A-Za-z0-9]+$/; var user2 = /^w{4,16}$/ var password1 = /^w{6,12}$/ if (!user1.test(user)) { alert("用户名格式错误,请重新输入"); document.myform.user.focus(); return false; } if (!user2.test(user)) { alert("用户名长度错误,请重新输入"); document.myform.user.focus(); return false; } if (!password1.test(password)) { alert("密码长度错误,请重新输入"); document.myform.password.focus(); return false; } if (password != passwordok) { alert("密码不一致,请重输入"); } } </script> <style> div { font-size: 30px; } </style> </head> <body background="image/beijing.jpg"> <div style="margin-left: 200px" class="div"> <p style="margin-left: 140px">注册页面</p> <form action="index2.jsp" method="post" name="myform"> <table border="0" align="left"> <tr height="40"> <td>用户名:</td> <td><input type="text" name="user">只能输入字母或数字,4-16个字符</td> </tr> <tr height="40"> <td>密 码:</td> <td><input type="password" name="password">密码长度6-12位</td> </tr> <tr height="40"> <td>确认密码:</td> <td><input type="password" name="passwordok"> </td> </tr> <tr height="40"> <td>性 别:</td> <td><input type="checkbox" value="男" name="sex">男 <input type="checkbox" value="女" name="sex">女</td> </tr> <tr height="40"> <td>电子邮件地址:</td> <td><input type="email" name="email"> </td> </tr> <tr height="40"> <td>出生日期:</td> <td><input type="text" name="year" style=" 10%">年 <select name="month"> <option value="" hidden="">请选择</option> <% for (int i = 1; i <= 12; i++) { %> <option value="<%=i%>"><%=i%></option> <% } %> </select> 月<select name="date"> <option value="" hidden="">请选择</option> <% for (int i = 1; i <= 31; i++) { %> <option value="<%=i%>"><%=i%></option> <% } %> </select>日 </tr> <tr height="40"> <td colspan="1" align="right"><input type="submit" name="Submit" value="提交" onfocus="Check()"></td> <td colspan="1" align="center"><input type="reset" name="reset" value="取消"></td> </tr> </table> </form> </div> </body> </html>
<%@page import="com.sun.xml.internal.txw2.Document"%> <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> </head> <body background="image/beijing.jpg" style="font-size:20px"> <% request.setCharacterEncoding("utf-8"); String user = request.getParameter("user"); String password = request.getParameter("password"); String sex = request.getParameter("sex"); String email = request.getParameter("email"); String year = request.getParameter("year"); String month = request.getParameter("month"); String date = request.getParameter("date"); request.setAttribute("user", user); %> <table border="1" align="left" style=" 30%;height: 50%" > <tr height="40"> <td>用户名:</td> <td><%=user%></td> </tr> <tr height="40"> <td>密码:</td> <td><%=password%></td> </tr> <tr height="40"> <td>性别:</td> <td><%=sex%></td> </tr> <tr height="40"> <td>邮箱:</td> <td><%=email%></td> </tr> <tr height="40"> <td>出生年月日:</td> <td><%=year%>年<%=month%>月<%=date%>日</td> </tr> </table> </body> </html>