onInvalid

Specification

Called once the submit is prevented due to invalid validation state of the form. Useful for any kind of custom logic based on the invalid fields.

Definition

1
type OnInvalid = ({
2
invalidFields: Object[], // Unordered list of invalid fields
3
fields: Object, // The state of the fields
4
form: ReactComponent // Reference to the Form component
5
}) => void
Copied!

Example

1
import React from 'react'
2
import { Form } from 'react-advanced-form'
3
import { Input } from 'react-advanced-form-addons'
4
5
export default class Example extends React.Component {
6
handleInvalidForm = ({ invalidFields, fields, form }) => {
7
// ...
8
}
9
10
render() {
11
return (
12
<Form onInvalid={this.handleInvalidForm}>
13
<Input name="username" required />
14
<button type="submit">Submit</button>
15
</Form>
16
)
17
}
18
}
Copied!
Last modified 3yr ago