Browse Source

门户网站联系电话验证

shaogen1995 3 years ago
parent
commit
db197d8b3c
1 changed files with 10 additions and 3 deletions
  1. 10 3
      web/src/views/user/userinfo.vue

+ 10 - 3
web/src/views/user/userinfo.vue

@@ -15,7 +15,7 @@
             <label for="female">女</label>
           </div>
           <div v-else class="input">
-            <input :disabled="sub.disable" :maxlength="sub.maxLength" v-model="editUserInfo[sub.key]" @blur="handleBlur(sub)" :type="sub.type || 'text'" />
+            <input :disabled="sub.disable" :maxlength="sub.maxLength" v-model="editUserInfo[sub.key]" @blur="handleBlur(sub)" :type="sub.type || 'text'"/>
             <!-- <span v-if="sub.key=='password'" class="primaryColor">修改密码</span> -->
           </div>
         </li>
@@ -56,7 +56,7 @@ const registerInfo = [
       {
         label: "联系电话",
         key: "phone",
-        maxLength: 20,
+        maxLength: 11,
         val: "",
         showValidate: true,
         validate: "",
@@ -123,7 +123,7 @@ export default {
         console.log(this.editUserInfo);
   },
   methods: {
-    handleBlur(item) {
+      handleBlur(item) {
       item.showValidate = !item.val
     },
     reset(){
@@ -137,6 +137,13 @@ export default {
           let sub = item[j]
           params[sub['key']] = this.editUserInfo[sub['key']]
           console.log(sub['key'],params[sub['key']]);
+          // 验证电话号码:
+          if(sub['key']==='phone') {
+            let pattern =/^1[3-9]\d{9}$/
+            if(!pattern.test(params[sub['key']])){
+              return alert('请输入合法联系电话')
+            }
+          }
           if(!params[sub['key']]&&params[sub['key']]!==0&&sub.required) {
             return alert('请补充信息')
           }