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
onChangeinstead ofallin 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
watchorgetValues, depending on your need. If you only need the value in Ubmit, thehandleSubmitpasses as argument for its function– Rafael Tavares