Antd Design 输入框自定义校验

2,004 阅读1分钟
前言

1、组件 Ant Design
2、类型:必填、禁止空格。。

使用
<Form
    name="basic"
    layout={'horizontal'}
    labelAlign='right'
>
  <Form.Item
    label="项目名称"
    name="projectName"
    rules={[
        { required: true, message: '请输入项目名称' },
        { pattern: /^[^\s]*$/, message: '不可输入空格'}
    ]}
  >
        <Input placeholder='请输入' maxLength={50} />
   </Form.Item>
</Form>