如何在不使用 reactjs 中的 getFieldDecorator 的情况下验证 ant design formitems?
How to validate ant design formitems without using getFieldDecorator in reactjs?
在 reactjs 中,我使用的是 ant design 表单。在那种形式下,我不想使用 getfielddecorator 进行默认验证。我想用我自己的 validation.How 验证字段,它验证了吗?
例如
<Form onSubmit={this.handlesubmit.bind(this)}> <FormItem>
<input/>
</FormItem>
<FormItem >
<input/>
</FormItem>
<ButtonAnt className="btng" type="primary" htmlType="submit">Save</ButtonAnt>
</Form>
根据 docs,
We provide properties like validateStatus
help
hasFeedback
to
customize your own validate status and message, without using
Form.create
and getFieldDecorator
.
此外,似乎有一个 validator
道具 (amongst others),您可以使用它来编写自己的验证器函数。
我是这样做的
<Form.Item
help={HasError && meta.error}
validateStatus={HasError ? "error" : "validating"}
>
<Input {...input} {...props} className={classes.Input}></Input>
</Form.Item>
在 reactjs 中,我使用的是 ant design 表单。在那种形式下,我不想使用 getfielddecorator 进行默认验证。我想用我自己的 validation.How 验证字段,它验证了吗? 例如
<Form onSubmit={this.handlesubmit.bind(this)}> <FormItem>
<input/>
</FormItem>
<FormItem >
<input/>
</FormItem>
<ButtonAnt className="btng" type="primary" htmlType="submit">Save</ButtonAnt>
</Form>
根据 docs,
We provide properties like
validateStatus
help
hasFeedback
to customize your own validate status and message, without usingForm.create
andgetFieldDecorator
.
此外,似乎有一个 validator
道具 (amongst others),您可以使用它来编写自己的验证器函数。
我是这样做的
<Form.Item
help={HasError && meta.error}
validateStatus={HasError ? "error" : "validating"}
>
<Input {...input} {...props} className={classes.Input}></Input>
</Form.Item>