源代码:
Register.jsp
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html > <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>注册页面</title> <script type="text/javascript"> function check(form) { with (form) { if (username.value == "") { alert("用户名不能为空"); return false; } else if (password.value == "" || password1.value == "") { alert("密码不能为空"); return false; } else return true; } } </script> <style> .a { border: 2px solid #a1a1a1; padding: 10px 40px; /* background:#dddddd; */ px; border-radius: 25px; } #bk { border: 3px solid #a1a1a1; padding: 10px 60px; /* background:#dddddd; */ px; border-radius: 25px; } .button { background-color: #ff8433; border: none; color: white; padding: 5px 10px; text-decoration: none; display: inline-block; font-size: 16px; margin: 2px 2px; cursor: pointer; } table{ margin: auto; } </style> </head> <body> <br> <br> <br> <h3 align="center">注册页面</h3> <hr> <form action="Rservlet" method="post" onsubmit="return check(this);"> <div style="text-align: center;"> <table> <tr> <td>用户名</td> <td><input id="bk" type="text" name="username" placeholder="6-12字母数字|字母开头" ></td> </tr> <tr> <td>密码</td> <td><input id="bk" type="password" name="password"placeholder="由6位英文和数字组成"></td> </tr> <tr> <td>姓名</td> <td><input id="bk" type="text" name="name"></td> </tr> <tr> <td>性别</td> <td><input type="radio" name="sex" value="male">Male <input type="radio" name="sex" value="female">Female</td> </tr> <tr> <td>手机号</td> <td><input id="bk" type="text" name="phone"></td> </tr> <tr> <td>地区</td> <td><select style="200px;hight:20px;" name="place"> <option value="天津">天津</option> <option value="河北">河北</option> <option value="北京">北京</option> <option value="唐山">唐山</option> </select></td> </tr> <tr> <td>邮箱</td> <td><input id="bk" type="text" name="email"></td> </tr> <tr> <td></td> <td><input class ="button" type="submit" value="注册"> <input class ="button" type="reset" value="重置"></td> </tr> </table> </div> </form> </body> </html>
login.jsp
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html > <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>注册页面</title> <script type="text/javascript"> function check(form) { with (form) { if (username.value == "") { alert("用户名不能为空"); return false; } else if (password.value == "" || password1.value == "") { alert("密码不能为空"); return false; } else return true; } } </script> <style> .a { border: 2px solid #a1a1a1; padding: 10px 40px; /* background:#dddddd; */ px; border-radius: 25px; } #bk { border: 3px solid #a1a1a1; padding: 10px 60px; /* background:#dddddd; */ px; border-radius: 25px; } .button { background-color: #ff8433; border: none; color: white; padding: 5px 10px; text-decoration: none; display: inline-block; font-size: 16px; margin: 2px 2px; cursor: pointer; } table{ margin: auto; } </style> </head> <body> <br> <br> <br> <h3 align="center">注册页面</h3> <hr> <form action="Rservlet" method="post" onsubmit="return check(this);"> <div style="text-align: center;"> <table> <tr> <td>用户名</td> <td><input id="bk" type="text" name="username" placeholder="6-12字母数字|字母开头" ></td> </tr> <tr> <td>密码</td> <td><input id="bk" type="password" name="password"placeholder="由6位英文和数字组成"></td> </tr> <tr> <td>姓名</td> <td><input id="bk" type="text" name="name"></td> </tr> <tr> <td>性别</td> <td><input type="radio" name="sex" value="male">Male <input type="radio" name="sex" value="female">Female</td> </tr> <tr> <td>手机号</td> <td><input id="bk" type="text" name="phone"></td> </tr> <tr> <td>地区</td> <td><select style="200px;hight:20px;" name="place"> <option value="天津">天津</option> <option value="河北">河北</option> <option value="北京">北京</option> <option value="唐山">唐山</option> </select></td> </tr> <tr> <td>邮箱</td> <td><input id="bk" type="text" name="email"></td> </tr> <tr> <td></td> <td><input class ="button" type="submit" value="注册"> <input class ="button" type="reset" value="重置"></td> </tr> </table> </div> </form> </body> </html>