//列表对话框验证规则 listDialogRules: { receiver_phone: [ { required: true, message: '请输入收货人手机号', trigger: 'blur' }, { validator: validateMobile.bind(this), trigger: 'blur' }, ], }, } }, 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18...
} else { return callback(new Error('请输入正确的身份证号')) } } } // 设置手机号的验证规则 const checkPhone = (rule, value, callback) => { if (!value) { callback(new Error('请输入联系方式')) } else { const reg = /^1[3|4|5|7|8][0-9]\d{8}$/ if (reg.test(value)...
data() {// 自定义验证constvalidPhone= (rule, value, callback) => {if(!value) {callback(newError('请输入电话号码')) }elseif(!isvalidPhone(value)) {//判断用户输入的值是否符合规则callback(newError('请输入正确的11位手机号码')) }else{callback() } }return{dialogFormVisible:false,form:...
},//列表对话框验证规则listDialogRules: {receiver_phone: [ {required:true,message:'请输入收货人手机号',trigger:'blur'}, {validator: validateMobile.bind(this),trigger:'blur'}, ], }, } }, config.js: constvalidateMobile =function(rule, value, callback) {letnewValue = value.replace(/[^0...
//列表对话框验证规则 listDialogRules: { receiver_phone: [ { required: true, message: '请输入收货人手机号', trigger: 'blur' }, { validator: validateMobile.bind(this), trigger: 'blur' }, ], }, } }, 1. 2. 3. 4. 5. 6.
简介:VUE element-ui之form表单自定义验证11位手机号码(封装验证规则) 步骤: 封装验证规则: export function isvalidPhone(phone) { const reg = /^1([38][0-9]|4[014-9]|[59][0-35-9]|6[2567]|7[0-8])\d{8}$/ return reg.test(phone) ...