我们在表单验证的时候,使用表单验证是很常见的场景
if (!this.form.name) {
this.utils.toast('姓名不能为空');
return
}
if (!this.form.cardId) {
this.utils.toast('身份证号码不能为空');
return
}
if (!this.form.phone) {
this.utils.toast('手机号码不能为空');
return
}
if (!this.form.address) {
this.utils.toast('所在地区不能为空');
return
}
if (!this.form.businessAddress) {
this.utils.toast('经营地址不能为空');
return
}
下面写一下手机验证的简单正则吧
const regu=/^1\d{10}$/;
if(regu.test(this.phone)&&this.check){
**显示接下来的程序运行**
}else{
this.utils.toast('手机号格式有误');
}