0
Even by entering the password it only activates the send button when I click out of the input or tab. Why is this happening? How can I correct?
const {register, handleSubmit, formState:{errors, isValid} } = useForm({mode:"all",});
<input
{...register("password", {
required: "Insira sua senha",
})}
type="password"
id="password"
name="password"
placeholder="*********"
value={password}
onChange={text => setPassword(text.target.value)}
/>
<button
disabled={!isValid}
type="submit">
Enviar
</button>
Try using
onChange
instead ofall
in themode
– Rafael Tavares
when I remove the value lines and onChange the input works right. but I need to use them in that input.
– Jhon
Ah, you’re squabbling with the library about who controls the input... Let the library take care of that and get the value with
watch
orgetValues
, depending on your need. If you only need the value in Ubmit, thehandleSubmit
passes as argument for its function– Rafael Tavares