// 自定义验证邮箱
var checkEmail = (rule, value, callback) => {
const regEmail = /^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+([a-zA-Z0-9_-])+/;
if (regEmail.test(value)) {
console.log(regEmail.test(value));
return callback();
} else {
callback(new Error("请输入合法邮箱"));
}
};
// 自定义验证手机号
var checkPhone = (rule, value, callback) => {
console.log(typeof value, "\\/");
const phoneReg = /^1[3|4|5|7|8][0-9]{9}/
if (!reg.test(value)) {
callback(new Error('请输入正确的电话号码或手机号'))
} else {
callback()
}
},
去引用就好 checkPhone
tel: [{
required: true,
message: "不能为空",
trigger: "blur"
},
{
validator:checkPhone,
trigger: "blur"
}
],