1.手机号是否正确校验
<el-input v-model="conentortel" oninput="if(value.length>11)value=value.slice(0,11)" type="Number" onkeyup="this.value = this.value.replace(/[^\d]/g,'');" placeholder="负责人电话" style="width:150px" prop="conentortel"></el-input>
export default{
data(){
var checkPhone = (rule, value, callback) => { // 手机号验证
if (!value) {
return callback(new Error('手机号不能为空'));
} else {
const reg = /^1[3456789]\d{9}$/
if (reg.test(value)) {
callback();
} else {
return callback(new Error('请输入正确的手机号'));
}
}
};
return {
conentortel:[
{required: true, message: '请填写联系人电话', trigger: 'blur'},
{validator: checkPhone, trigger: 'blur'}
],
}
}
}