赞
踩
- created() {
- this.initializeIdentityNoRules();
- },
-
- initializeIdentityNoRules() {
- this.identityNoRules = [
- { required: true, message: '请输入证件号码', trigger: 'blur' }, // 当输入框失去焦点时触发校验
- { validator: this.validateIdentityNo, trigger: 'blur' }, // 身份证规则校验
- ];
- },
- isValidIdentityNo(value) {
- // 统一社会信用代码
- const regExp = /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/;
- return regExp.test(value);
- },
- validateIdentityNo(rule, value, callback) {
- if (this.form.identityType === '1' && !this.isValidIdentityNo(value)) {
- callback(new Error('请输入有效的居民身份证号码'));
- } else {
- callback();
- }
- },
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。