html input框
<input type="tel" placeholder="请输入手机号" class="log_input" v-model.trim="tel" @focus="textF" @blur="change" />
js 方法验证
blur(event){
if(this.pass === "" ){
this.blurShow = "密码不能为空"
event.target.style.borderColor = 'red';
}else{
this.blurShow = ""
}
},
change(event) {
let myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
if(this.tel && myreg.test(this.tel)) {
this.num = false;
this.numMsg = '';
event.target.style.borderColor = 'gainsboro';
}else if(this.tel === ""){
this.num = true;
this.numMsg = '手机号不能为空';
event.target.style.borderColor = 'red';
} else{
this.num = true;
this.numMsg = '手机号格式不正确';
event.target.style.borderColor = 'red';
}
},