likes
comments
collection
share

React Ant Design 表单 添加 正则

作者站长头像
站长
· 阅读数 19

描述:

给表单 添加 正则
<Form.Item label="左侧的 label 信息 写在这里">
  {getFieldDecorator('userName', {
    rules: [
      {
        required: true,
        pattern: new RegExp(/^(?!(\s+$))^[\w\s]+$/),
        message: '输入的值不正确的提示写在这里',
      },
    ],
  })(<Input placeholder="请输入默认提示 信息" allowClear />)}
</Form.Item>