antd-vue中, form表单常用的校验

5,627 阅读1分钟

邮箱:

<a-input v-decorator="['email', { rules: [{type: 'email',message: '请输入有效的邮箱'}]}]" />

手机号码:

<a-input-number v-decorator="['mobile', { rules: [{ pattern: /^1[3456789]\d{9}$/, message: '手机号码格式错误' }] }]" />

电话号码:

<a-input v-decorator="['Phone', { rules: [{ pattern: /^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/, message: '电话号码格式错误' }] }]" />

邮编:

<a-input-number v-decorator="['officeEmailCode', { rules: [{ pattern: /^[0-9]{6}$/, message: '邮编格式错误' }] }]" />

传真:

<a-input v-decorator="['officeFax', { rules: [{ pattern: /^(?:\d{3,4}-)?\d{7,8}(?:-\d{1,6})?$/, message: '传真格式错误' }] }]" />

身份证:

/^[1-9][0-9]{5}([1][9][0-9]{2}|[2][0][0|1][0-9])([0][1-9]|[1][0|1|2])([0][1-9]|[1|2][0-9]|[3][0|1])[0-9]{3}([0-9]|[X])$/

护照(国内):

/(^[EeKkGgDdSsPpHh]\d{8}$)|bai(^(([Ee][a-fA-F])|([DdSsPp][Ee])|([Kk][Jj])|([Mm][Aa])|(1[45]))\d{7}$)/