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>
You have to click the "+ Add Field" button for the dynamic form to add and show the first field as shown here..
Form validation in React allows an error message to be displayed if the user has not correctly filled out the form with the expected type of input. There are several ways to validate forms in React; however, this shot will focus on creating a validator function with validation rules.
Just use Form. Item directly: // antd v3 const Demo = ({ form: { getFieldDecorator } }) => ( <Form> <Form. Item> {getFieldDecorator('username', { rules: [{ required: true }], })(<Input />)} </Form.
How do you delete values after submitting a form? The reset() method resets the values of all elements in a form (same as clicking the Reset button). Tip: Use the submit() method to submit the form.
I do it like this
<Form.Item
help={HasError && meta.error}
validateStatus={HasError ? "error" : "validating"}
>
<Input {...input} {...props} className={classes.Input}></Input>
</Form.Item>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With