No way to prevent default browser input validation
See original GitHub issueCurrently there doesn’t seem to be any direct way to prevent the browser’s default validation behaviour. eg. when the form contains an input of type=“number” and you enter a non-number string and submit, then in Chrome the validation tooltip will appear on the input.
Standard way to disable this functionality on a normal form, would be to specify the novalidate attribute. This unfortunately doesn’t work with Formsy.Form.
Currently the only workaround I found was to wrap the Formsy.Form element in an outer form tag and specify novalidate there.
<form novalidate>
<Formsy.Form>...</Formsy.Form>
</form>
But this will probably have some other disadvantages. Would be great if you could support the novalidate attribute! 😃
Issue Analytics
- State:
- Created 8 years ago
- Comments:18 (10 by maintainers)
Top Results From Across the Web
How to prevent the default browser input validation?
I've tried to implement event. preventDefault(); however it doesn't seem to work in my case.
Read more >Avoid Default Field Validation - Adrian Roselli
I made an example on CodePen that uses an email field ( type="email" ), is required ( required ), and uses a pattern...
Read more >Event.preventDefault() - Web APIs | MDN
The preventDefault() method of the Event interface tells the user agent that if the event does not get explicitly handled, its default ......
Read more >Validation · Bootstrap v5.0
For custom Bootstrap form validation messages, you'll need to add the novalidate boolean attribute to your <form> . This disables the browser default...
Read more >How to Manage Browser Defaults with event.preventDefault ...
Browsers have default interactions and behaviors for different events. For example, when a user clicks a "submit" button on a form, the form...
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
There’s another case where
formNoValidate
works:I think what happens here is that in a form with a single “texty” type of input, that element also takes the role of the submit button, so
formNoValidate
applies and native validation is skipped.In the docs, it maybe worth noting that formsy-react isn’t performing any “special magic”, and provide a link to the html5 spec?
I think @dprentis is right, the
formnovalidate
attribute is only allowed on submit and image input types. So if it’s present on the default button for the form, native validation is skipped. Ifformnovalidate
is not present on the default button, then anovalidate
attribute on the form element comes into play.From what I can see, adding
formNoValidate
to other inputs (as shown in the API documentation) has no effect.Native validation shown:
Native validation supressed: