b9b6a2d3 by renchao@pashanhoo.com

style:证书领取表单验证

1 parent c45b2615
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-09-14 16:37:15
* @LastEditTime: 2023-10-17 16:16:41
-->
<template>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px">
......@@ -64,6 +64,27 @@
</el-form>
</template>
<script>
const checkPhone = (rule, value, callback) => {
let regPone = null
let mobile = /^(1[3456789]\d{9})$/ //手机号
let tel = /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/ // 座机
if (value && value[0] === '0') {// 检查 value 是否存在并且不是 null 或者 undefined
regPone = tel
} else if (value && value[0] !== '0') {
regPone = mobile
}
if (regPone === null) {
return callback(
new Error('请输入电话')
)
} else if (!regPone.test(value)) {
return callback(
new Error("请输入正确的电话格式,其中座机格式'区号-座机号码'")
)
} else {
callback()
}
};
import Vue from 'vue'
import store from '@/store/index.js'
import table from "@/utils/mixin/table";
......@@ -104,7 +125,7 @@
{ required: true, message: '请输入证件号', trigger: 'blur' }
],
lzrdh: [
{ required: true, message: '请输入电话号码', trigger: 'blur' }
{ required: true, validator: checkPhone, trigger: ["blur"] }
]
},
tableData: {
......