关于校验问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | <%@ page language= "java" contentType= "text/html; charset=UTF-8" pageEncoding= "UTF-8" %> <% String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/" + request.getServletContext().getContextPath(); %> <!DOCTYPE html> <html> <head> <meta charset= "UTF-8" > <title>注册界面</title> </head> <body> <center> <h1>用户注册</h1> <form action= "<%=basePath%>/RegistServlet" method= "post" enctype= "multipart/form-data" > <table width= "400px" cellspacing= "0px" cellpadding= "0px" border= "1px" > <tr> <td>用户名</td> <td><input type= "text" name= "username" pattern= "[a-zA-Z_0-9] {3,12}" required= "required" placeholder= "用户名为3-12位字母数字或下划线组合" ></td> </tr> <tr> <td>密 码</td> <td><input type= "password" name= "password" pattern= "[0-9] {6,12}" required= "required" placeholder= "密码长度为6-12位的纯数字" id= "password" ></td> </tr> <tr> <td>确认密码</td> <td><input type= "password" name= "checkPWD" pattern= "[0-9] {6,12}" required= "required" placeholder= "密码长度为6-12位的纯数字" "></td> </tr> <tr> <td>手机号码</td> <td><input type= "text" name= "phone" pattern= "[1][3578]\\d{9}" required= "required" placeholder= "请输入正确的手机号码格式" ></td> </tr> <tr> <td>邮箱</td> <td><input type= "email" name= "email" required= "required" placeholder= "请输入正确邮箱格式" required= "required" ></td> </tr> <tr> <td colspan= "2" style= "text-align:center" > <input type= "submit" value= "注册" > <input type= "reset" value= "重置" > </td> </tr> </table> </form> </center> </body> </html> |
目前只写了前端校验,请问老师这样写有什么不对吗?为什么输入正确格式依然提示格式不正确
1
收起
正在回答
1回答
同学的正则表达式之间多了一个空格,把空格去掉以后再试下;
手机号码的验证改为:[1][3578]\d{9}
修改以后再试下,祝学习愉快!
从网页搭建入门Java Web2018版
- 参与学习 人
- 提交作业 1088 份
- 解答问题 10204 个
如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧