判断身份证号码
let reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
if(!reg.test(this.cardNo)){
uni.showToast({
title: '身份证输入不正确',
})
return
}
判断手机号
function checkPhone(){
varphone = $(".phone").val();
if(!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(phone))){
alert("手机号码不合法,请重新输入");
returnfalse;
}
}
验证邮箱
var reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
if(reg.test(email)){
alert("邮箱格式正确");
}else{
alert("邮箱格式不正确");
}
验证密码
varreg =newRegExp("^(?![A-Za-z]+$)(?![A-Z\\d]+$)(?![A-Z\\W]+$)(?![a-z\\d]+$)(?![a-z\\W]+$)(?![\\d\\W]+$)^[a-zA-Z0-9!#*_]{8,20}$");
if (!reg.test(pass)) {
isStrongPassword=false;
}
varregex =newRegExp('(?!^([0-9]+|[a-zA-Z]+|[!#*_]+)$)^[a-zA-Z0-9!#*_]{6,16}$');