<Form.Item
className={styles.formItem}
label="联系方式"
labelCol={{ span: 7 }}
name={[field.name, 'participant_phone']}
fieldKey={[field.fieldKey, 'participant_phone']}
rules={[
{
validator: (_, value) =>
(/^1(3|4|5|6|7|8|9)\d{9}$/.test(value)) || !value ? Promise.resolve() : Promise.reject(new Error('请填写正确手机格式'))
},
]}
>
<Input
style={{ width: 150 }}
className={styles.input}
/>
</Form.Item>
关键操作:
编写校验 定义返回
rules={[
{
validator: (_, value) =>
(/^1(3|4|5|6|7|8|9)\d{9}$/.test(value)) || !value ? Promise.resolve() : Promise.reject(new Error('请填写正确手机格式'))
},
]}