二代身份证正则表达

第二代身份证18位:

/^[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]$/

uni-app 校验列子

if (!(/^[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]$/.test(this.idCard))) {
uni.showModal({
content: "请输入正确的身份证号",
confirmText: "确定",
showCancel: false,
success: function() {
return;
}
})
return;
}

posted @ 2019-05-24 11:40  沧海一粟95  阅读(327)  评论(0编辑  收藏  举报