第六周jsp
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> <style type="text/css"> span { color: red; } </style> <script type="text/javascript"> window.onload = function() { var flag1 = false; var flag2 = false; var flag3 = false; var flag4 = false; document.getElementById("username").onblur = function() { if (!/^[0-9a-zA-Z]{4,16}$/.test(document.getElementById("username").value)) { flag1 = false; document.getElementById("checkText").innerText = "用户名输入不合法"; } else { flag1 = true; document.getElementById("checkText").innerText = ""; } } document.getElementById("password").onblur = function() { if (!/^[0-9a-zA-Z]{6,12}$/.test(document.getElementById("password").value)) { flag2 = false; document.getElementById("checkPassword").innerText = "密码输入不合法"; } else { flag2 = true; document.getElementById("checkPassword").innerText = ""; } } document.getElementById("rePassword").onblur = function(){ if(document.getElementById("password").value !== document.getElementById("rePassword").value){ flag3 = false; document.getElementById("checkRePassword").innerText = "两次输入不一致"; } else { flag3 = true; document.getElementById("checkRePassword").innerText = ""; } } document.getElementById("email").onblur = function(){ if(!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(document.getElementById("email").value)){ flag4 = false; document.getElementById("checkEmail").innerText = "邮箱格式错误"; } else{ flag4 = true; document.getElementById("checkEmail").innerText = ""; } } } </script> </head> <body> <form action="2.jsp"> <table border="0px" cellspacing="" cellpadding=""> <tr> <td>用户名:</td> <td><input type="text" name="username" id="username" value="" />只能输入字母或数字,4-16个字符</td> <td><span id="checkText"></span></td> </tr> <tr> <td>密码:</td> <td><input type="password" name="password" id="password">密码长度6-12位</td> <td><span id="checkPassword"></span></td> </tr> <tr> <td>确认密码:</td> <td><input type="password" id="rePassword" /></td> <td><span id="checkRePassword"></span></td> </tr> <tr> <td>性别:</td> <td><input type="radio" name="sex" id="sex1" value="男" checked="" /> 男 <input type="radio" name="sex" id="sex0" value="女" /> 女 </td> </tr> <tr> <td>电子邮件地址:</td> <td><input type="email" name="email" id="email" value="" /> 请输入正确的邮件地址</td> <td><span id="checkEmail"></span></td> </tr> <tr> <td>出生日期:</td> <td><input type="date" name="date" id="date" /></td> </tr> <tr> <td></td> <td><input type="submit" id="submit" value="同意以下协议条款并提交" /></td> </tr> <tr> <td colspan="2"><textarea rows="10" cols="50">一,总则 1.1用户应当同意本协议的条款并按照界面上的提示完成全部注册程序,以下省略.. ...........................................................................</textarea></td> </tr> </table> </form> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <% String username = request.getParameter("username"); String password = request.getParameter("password"); String sex = request.getParameter("sex"); String email = request.getParameter("email"); String date = request.getParameter("date"); %> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <style type="text/css"> tr{ font-size: 30px; color: deeppink; } </style> <body> <table border="0px" cellspacing="" cellpadding=""> <tr> <th colspan="2">您注册的信息如下:</th> </tr> <tr> <td>用户名:</td> <td><%=username%></td> </tr> <tr> <td>密码:</td> <td><%=password%></td> </tr> <tr> <td>性别:</td> <td><%=sex%></td> </tr> <tr> <td>电子邮件:</td> <td><%=email%></td> </tr> <tr> <td>出生日期:</td> <td><%=date%></td> </tr> </table> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> 求平均值 <form action="NewFile2.jsp" method=post"> <table> <tr> <td>姓名</td> <td><input type="text" name="user"/></td> </tr> <tr> <td>性别</td> <td><input type="radio" name="sex" value="男"/>男</td> <td><input type="radio" name="sex" value="女"/>女</td> </tr> <tr> <td>班级</td> <td><select name="bj"> <option value="1903">1903</option> <option value="1902">1902</option> <option value="1901">1901</option></select> </td> </tr> <tr> <td>语文</td> <td><input type="number" name="ch"/></td> </tr> <tr> <td>数学</td> <td><input type="number" name="ma"/></td> </tr> <tr> <td>英语</td> <td><input type="number" name="en"/></td> </tr> <tr> <td> <input type="submit" value="提交"/></td> <td><input type="reset" value="重置"/></td> </tr> </table> </form> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> <% request.setCharacterEncoding("utf-8"); String str=request.getParameter("user"); String user=new String(str.getBytes("ISO-8859-1"),"utf-8"); String a=request.getParameter("sex"); String sex=new String(a.getBytes("ISO-8859-1"),"utf-8"); String bj=request.getParameter("bj"); String ch=request.getParameter("ch"); double c=ch==null?-1:Double.parseDouble(ch); String ma=request.getParameter("ma"); double m=ma==null?-1:Double.parseDouble(ma); String en=request.getParameter("en"); double e=en==null?-1:Double.parseDouble(en); double sum=c+m+e; double avg=sum/3; %> 你好!<%=bj %>班的<%=user %>同学!<br> 性别:<%=sex %><br> 您的各科平均分为<%=avg%> </body> </html>