vue身份证正则校验

 对身份证号码进行正则校验

let regs = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$)/;
if (!this.oldIdCard) {      
  uni.showToast({
  title: '请输入身份证号码',
  icon: 'none'
})
return
} else if (!regs.test(this.oldIdCard)) {      
   uni.showToast({
   title: '身份证号码不正确',
   icon: 'none'
})
};

猜你喜欢

转载自blog.csdn.net/weixin_57607714/article/details/124490583