// 自定义手机号校验规则
const validatePhone = (_, value) => {
const phoneRegex = /^1[3456789]\d{9}$/;
if (!value || phoneRegex.test(value)) {
return Promise.resolve();
}
return Promise.reject(new Error('请输入有效的手机号码'));
};
<Form.Item
name="mobile"
label="手机号"
rules={[
{
required: true,
message: '请输入手机号',
},
{ validator: validatePhone }
]}
>
<Input maxLength={200} placeholder="请输入手机号" />
</Form.Item>
标签:phoneRegex,const,手机号,antd4,value,表单,return From: https://www.cnblogs.com/Simoon/p/18169957