style:证书领取表单验证
Showing
1 changed file
with
23 additions
and
2 deletions
1 | <!-- | 1 | <!-- |
2 | * @Description: | 2 | * @Description: |
3 | * @Autor: renchao | 3 | * @Autor: renchao |
4 | * @LastEditTime: 2023-09-14 16:37:15 | 4 | * @LastEditTime: 2023-10-17 16:16:41 |
5 | --> | 5 | --> |
6 | <template> | 6 | <template> |
7 | <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px"> | 7 | <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px"> |
... | @@ -64,6 +64,27 @@ | ... | @@ -64,6 +64,27 @@ |
64 | </el-form> | 64 | </el-form> |
65 | </template> | 65 | </template> |
66 | <script> | 66 | <script> |
67 | const checkPhone = (rule, value, callback) => { | ||
68 | let regPone = null | ||
69 | let mobile = /^(1[3456789]\d{9})$/ //手机号 | ||
70 | let tel = /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/ // 座机 | ||
71 | if (value && value[0] === '0') {// 检查 value 是否存在并且不是 null 或者 undefined | ||
72 | regPone = tel | ||
73 | } else if (value && value[0] !== '0') { | ||
74 | regPone = mobile | ||
75 | } | ||
76 | if (regPone === null) { | ||
77 | return callback( | ||
78 | new Error('请输入电话') | ||
79 | ) | ||
80 | } else if (!regPone.test(value)) { | ||
81 | return callback( | ||
82 | new Error("请输入正确的电话格式,其中座机格式'区号-座机号码'") | ||
83 | ) | ||
84 | } else { | ||
85 | callback() | ||
86 | } | ||
87 | }; | ||
67 | import Vue from 'vue' | 88 | import Vue from 'vue' |
68 | import store from '@/store/index.js' | 89 | import store from '@/store/index.js' |
69 | import table from "@/utils/mixin/table"; | 90 | import table from "@/utils/mixin/table"; |
... | @@ -104,7 +125,7 @@ | ... | @@ -104,7 +125,7 @@ |
104 | { required: true, message: '请输入证件号', trigger: 'blur' } | 125 | { required: true, message: '请输入证件号', trigger: 'blur' } |
105 | ], | 126 | ], |
106 | lzrdh: [ | 127 | lzrdh: [ |
107 | { required: true, message: '请输入电话号码', trigger: 'blur' } | 128 | { required: true, validator: checkPhone, trigger: ["blur"] } |
108 | ] | 129 | ] |
109 | }, | 130 | }, |
110 | tableData: { | 131 | tableData: { | ... | ... |
-
Please register or sign in to post a comment