React-hook-form: [Question] How to disable native HTML 5 validation

Created on 7 Oct 2019  路  3Comments  路  Source: react-hook-form/react-hook-form

I'm passing a {nativeValidation: false} option to the useFormContext hook although it is documented as a default value. However, even when I use custom validate function as an option to the register method of an email input type I can see unneeded native Chrome bubble with yellow exclamation mark. How can I get rid of it? The type="email" attribute of an input is convenient for determining what validation function to use in React components but this also causes HTML 5 browser-native design elements to appear which is not suitable for my project.

So the question is how to disable that behavior.

As a workaround, I passed a custom react prop to a component wrapping my input element (dataType="email")

Related StackOverflow question

question

Most helpful comment

<form onSubmit={handleSubmit(onSubmit)} noValidate>

use noValidate

All 3 comments

<form onSubmit={handleSubmit(onSubmit)} noValidate>

use noValidate

thanks @danihazler or you can pass type="text" and write a regex yourself :)

Thank you @danihazler! noValidate attribute does exactly what I wanted.

Was this page helpful?
0 / 5 - 0 ratings