我怎么让刷新页面的时候先不去验证对不对呢?
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | <!DOCTYPE html> < html > < head > < meta charset = "utf-8" > < meta http-equiv = "X-UA-Compatible" content = "IE=edge" > < title >html5表单美化综合案例演示美化案例</ title > < meta name = "viewport" content = "initial-scale=1, maximum-scale=1" > </ head > < style > .onelist{margin:10px 0 5px 12px;} .onelist label{width:80px;display:inline-block} .onelist input,.onelist select{height:25px;line-height:25px;width:220px;border-radius:3px;border:1px solid #e2e2e2;} .onelist input[type="submit"]{width:150px;height:30px;line-height:30px;} .myform select:required, .myform input:required, .myform textarea:required { background: #fff url(img/star.jpg) no-repeat 99% center; } .myform select:required:valid, .myform input:required:valid, .myform textarea:required:valid { background: #fff url(img/right.png) no-repeat 99% center; box-shadow: 0 0 5px #5cd053; border-color: #28921f; } .myform select:focus:invalid, .myform input:focus:invalid, .myform textarea:focus:invalid { background: #fff url(img/error.png) no-repeat 99% center; box-shadow: 0 0 5px red; border-color: red; outline: red solid 1px; } </ style > < body > < form class = "myform" onsubmit = "return checkForm();" method = "post" > < div class = "onelist" > < label for = "UserName" >手机号</ label > < input name = "UserName" id = "UserName" type = "text" placeholder = "请输入手机号码" pattern = "^1[0-9]{10}$" required oninvalid = "this.setCustomValidity('请输入正确的号码');" oninput = "setCustomValidity('')" > </ div > < div class = "onelist" > < label for = "Password" >密码</ label > < input name = "Password" id = "Password" type = "password" placeholder = "6~20位" class = "" pattern = "^[a-zA-Z0-9]\w{5,19}$" required oninvalid = "this.setCustomValidity('6~20字母数字或下划线');" oninput = "setCustomValidity('')" onchange = "checkPassword()" > </ div > < div class = "onelist" > < label for = "Repassword" >确认密码</ label > < input name = "Repassword" id = "Repassword" type = "password" placeholder = "确认密码" class = "" required onchange = "checkPassword()" > </ div > < div class = "onelist" > < label for = "Repassword" >了解方式</ label > < select name = "konw" required> < option value = "" >==请选择==</ option > < option value = "1" >搜索引擎</ option > < option value = "2" >朋友圈</ option > < option value = "3" >朋友推广</ option > < option value = "4" >广告投放</ option > </ select > </ div > < div class = "onelist" >< input type = "submit" value = "提交" ></ div > </ form > < script type = "text/javascript" > function checkPassword() { var pass1 = document.getElementById("Password"); var pass2 = document.getElementById("Repassword"); if (pass1.value != pass2.value) pass2.setCustomValidity("两次输入的密码不匹配"); else pass2.setCustomValidity(""); } // 验证表单 function checkForm() { // ajax检测账号是否已存在 // return false; } </ script > </ body > </ html > |
20
收起
正在回答 回答被采纳积分+1
2回答
响应式开发与常用框架 2018
- 参与学习 人
- 提交作业 2198 份
- 解答问题 5012 个
如果你有web端基础,既想进阶,又想进军移动端开发,那就来吧,我们专题为你带来的课程有HTML5、CSS3、移动基础、响应式、bootstrap、less等,让你在前端道路上畅通无阻!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧