I made multi step form. I navigate between steps with "back" and "next" buttons. I want to disable next button if current visible inputs aren't valid. Currently validation is applied but i can still navigate forward and back between steps. I could use field value and for each one individual check if it is valid but this seems very inefficient any other suggestions.
Just for visualization purposes here is my code
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
{currentStep}
<div className="flex justify-between gap-4">
{!isFirstStep && (
<Button type="button" variant="outline" onClick={back}>
Back
</Button>
)}
{!isLastStep ? (
<Button onClick={next}>Next</Button>
) : (
<Button>Submit</Button>
)}
</div>
</form>
</Form>
);