Vue element ui 校验From表单 input输入多个邮件分割校验
validator: function (rule, value, callback) {
let testStr = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
let emailArray = value?value.split(';'):[];
console.log(emailArray);
if(emailArray.length==0){
callback(new Error('不能为空'))
}else{
let newArray = emailArray.filter(item=>{
return !testStr.test(item)
});
if(newArray.length>0){
callback(new Error("请输入正确的邮箱!"))
}else{
callback();
}
}
},