<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <style> .a{ margin-top: 20px; } .b{ font-size: 20px; width: 160px; color: white; background-color: greenyellow; } </style> </head> <body> <% Object message = request.getAttribute("message"); if(message!=null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%} %> <div align="center"> <h1 style="color: red;">注册</h1> <form action="servlet?method=add" method="post" onsubmit="return check()"> <div class="a"> 登录账号<input type="text" id="a1"name="a1" value=""/> </div> <div class="a"> 登录密码:<input type="password" id="b"name="b" value="" /> </div> 性别: <select name="d" > <option value="男">男</option> <option value="女">女</option> </select> <div class="a"> 姓名:<input type="text" name="c" value="" /> </div> <div class="a"> 学号:<input type="text" id="e1"name="e1" value="" /> </div> <div class="a"> 电子邮件:<input type="text" id="f1" name="f1" value="" /> </div> <div class="a"> 所在学院:<input type="text" name="f11" value="" /> </div> <div class="a"> 所在系:<input type="text" name="f12" value="" /> </div> <div class="a"> 所在班级:<input type="text" name="f13" value="" /> </div> 入学年份(届)<select name="f14"> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> </select>届 <div class="a"> 生源地:<input type="text" name="f15" value=""/> </div> <div class="a"> 备注:<textarea rows="10" cols="50" name="f16"> </textarea> </div> <div class="a"> <button type="submit" class="b">保 存</button> </div> </form> </div> <script type="text/javascript"> function check() { var a1 = document.getElementById("a1"); var b = document.getElementById("b"); var e1 = document.getElementById("e1"); var f1 = document.getElementById("f1"); if (!a1.value.match(/^[a-zA-Z]\w{5,11}$/)) { alert("用户名由六到十二英文字符和数字组成,以英文字母开头"); a1.focus(); return false; } else if (!b.value.match(/^[A-Za-z0-9]\w{7,20}$/)) { alert(" 密码由八 位 以上英文 和数 字 组成"); b.focus(); return false; } else if(e1.value<"20180000"|| e1.value>"20189999") { alert(" 学号由2018开头的八位组成"); e1.focus(); return false; } else if (!f1.value.match(/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/)) { alert(" 邮箱格式错误"); f1.focus(); return false; } } </script> </body> </html>
原文地址:https://www.cnblogs.com/xiaofengzai/p/11717285.html
时间: 2024-10-09 14:29:41