I would like to know how to disable a button only when both Name and State in the following code are empty.In other words, I would like to know how to make it so that the button can be pressed only when both name and state are entered, regardless of whether the email is null or not.
import React from "react";
import { useForm, SubmitHandler } from "react-hook-form";
type FormValues = {
name: string;
state: string;
email: string;
};
export default function App() {
const { register, handleSubmit } = useForm<FormValues>();
const onSubmit: SubmitHandler<FormValues> = data => console.log(data);
return (
<form onSubmit={handleSubmit(onSubmit)}>
<input {...register("name")} />
<input {...register("state")} />
<input type="email" {...register("email")} />
<input type="submit" />
</form>
);
}