<Form.Item
label="学生编码"
name="stuId"
validateFirst={true} // 出错时两个校验分别生效
rules={[
{ required: true, message: '学生编码不能为空' },
{ validator: (rule, value) => {
let reg = new RegExp(/[\u4E00-\u9FA5]/);
if(reg.test(value)) {
return Promise.reject('学生编码不能为汉字');
} else {
return Promise.resolve();
}
}},
]}
>
<Input placeholder="请填写学生编码" className="create-input" />
</Form.Item>
标签:return,自定义,Form,Promise,AntD,reg
From: https://www.cnblogs.com/ZerlinM/p/16977702.html