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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
| <!DOCTYPE html> <html> <head></head>
<body> <form id="registerForm" action="regist_success.html"> <div class="form-item"> <div> <label>用户名称:</label> <input v-model="username" type="text" placeholder="请输入用户名" /> <span></span> </div> <span>{{usernameCheckMessage}}</span> </div>
<div class="form-item"> <div> <label>用户密码:</label> <input v-model="password" type="text" placeholder="请输入密码" /> </div> <span class="errMess">密码的长度至少为8位</span> </div>
<div> <div class="form-item"> <input v-model="passwordConfirm" type="text" placeholder="请再次输入密码" /> </div> <span class="errMess">两次输入的密码不一致</span> </div>
<div class="form-item"> <div> <label>用户邮箱:</label> <input v-model="email" type="text" placeholder="请输入邮箱" /> </div> <span class="errMess">请输入正确的邮箱格式</span> </div>
<div class="form-item"> <div> <label>验证码:</label> <div class="verify"> <input v-model="code" type="text" placeholder="" /> <img src="" alt="" /> </div> </div> <span class="errMess">请输入正确的验证码</span> </div>
<button type="submit" @click="registerCheck" class="btn">注册</button> </form> </body>
<script src="../script/vue.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript"> new Vue({ "el":"#registerForm", "data":{ "username":"", "password":"", "passwordConfirm":"", "email":"", "code":"", "usernameCheckMessage":"" }, "watch":{ "username":function(inputValue){ var usernameRegExp = /^[A-Z,a-z,0-9,_]{5,8}$/;
if (usernameRegExp.test(this.username)) { this.usernameCheckMessage = ""; } else { this.usernameCheckMessage = "用户名不符合规则"; } } }, "methods":{ "registerCheck":function(){ var usernameRegExp = /^[A-Z,a-z,0-9,_]{5,8}$/; if (!usernameRegExp.test(this.username)) { event.preventDefault(); return; }
var passwordRegExp = /^[A-Z,a-z,0-9,_]{5,8}$/; if (!passwordRegExp.test(this.password)) { event.preventDefault(); return; }
if (this.password != this.passwordConfirm) { event.preventDefault(); return; }
var emailRegExp = /^[a-zA-Z0-9_\.-]+@([a-zA-Z0-9-]+[\.]{1})+[a-zA-Z]+$/; if (!emailRegExp.test(this.email)) { event.preventDefault(); return; }
var codeRegExp = /[A-Z,a-z,0-9]{5}/; if (!codeRegExp.test(this.code)) { event.preventDefault(); return; } } } }); </script> </html>
|