How to validate ant design formitems without using getFieldDecorator in reactjs?

Janani picture Janani · Dec 6, 2017 · Viewed 27.3k times · Source

In reactjs i am using ant design form. In that form i dont want default validation using getfielddecorator. I want to validate fields with my own validation.How it validate? For example

 <Form onSubmit={this.handlesubmit.bind(this)}>                                                                                                        <FormItem>                                                       
    <input/>                                              
</FormItem>
 <FormItem >                                                       
  <input/>                                                                                                                      
 </FormItem>                                                
<ButtonAnt className="btng" type="primary" htmlType="submit">Save</ButtonAnt>                                                   
 </Form>  

Answer

Dane picture Dane · Dec 6, 2017

According to the docs,

We provide properties like validateStatus help hasFeedback to customize your own validate status and message, without using Form.create and getFieldDecorator.

Also, it seems there is a validator prop (amongst others) that you can use to write your own validator function.