ant design vue表单中自定义检验规则,如手机号码
<a-form-itemlabel="手机号码":label-col="{ span: 8 }":wrapper-col="{ span: 16 }"><a-inputv-de...
·
<a-form-item
label="手机号码"
:label-col="{ span: 8 }"
:wrapper-col="{ span: 16 }"
>
<a-input
v-decorator="[
'user_phone',
{rules: [{ required: true, message: '请输入手机号码', whitespace: true},{validator:phoneCheck.bind(this)}]}
]" />
</a-form-item>
phoneCheck (rule, value, callbackFn) {
const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
if (!reg.test(value)) {
callbackFn('请输入手机号码')
return
}
callbackFn()
},
更多推荐
已为社区贡献15条内容
所有评论(0)