Form reset or prevent validation
See original GitHub issueHi,
Thanks a lot for this library. It has been really helpful so far, but I found a caveat… Or at least I am not sure to go around it.
I am using availity
to validate my inputs on a form. Once it is valid I send an ajax request and I reset the form. But I came upon a problem.
So far all my inputs have:
<AvField name="xxx" required value={this.state.xxx}></AvField>
So the only way I found to reset my form is to do a this.setState({xxx: ''})
But that triggers the validation submit and ends up my form having errors everywhere…
How would you reset the form ‘properly’… I have been struggling with that for a while now…
Thanks a lot
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Prevent validation on form.reset() - javascript - Stack Overflow
The problem is, that when the form resets, it causes the validation to fire, and displays the error message to the user. How...
Read more >Reset Validation On An Angular Form - Upmostly
Some forms require the ability to “clear” all input and “reset” the form. I struggled through a few different ways of clearing a...
Read more >useForm - reset - React Hook Form
Performant, flexible and extensible forms with easy-to-use validation. ... Avoid calling reset before useForm 's useEffect is invoked, this is because ...
Read more >Reactive Form - Reset input validation after change
When set to 'Built-In Validations=No' then you've effectively disabled all checking (and resetting) of the form's fields.
Read more ><input type="reset"> - HTML: HyperText Markup Language
Note: You should usually avoid including reset buttons in your forms. They're rarely useful, and are instead more likely to frustrate users ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To reset the form, you can set
key
onAvForm
to something else. This will cause react to create a new instance of AvForm, clearing the internal state.It’s more of a hack way of reseting, but it’s easy to implement (no need to get a ref or understand the internal workings of the components) https://stackblitz.com/edit/reactstrap-validation-v2-cl7jvy?file=Example.js