Skip to content
Submitted over 2 years ago

Responsive Multi-step-form using Nextjs, React Hook Form, Zod

accessibility, react, typescript, tailwind-css
LVL 2
@shamim-001
A solution to the Multi-step form challenge

Solution retrospective


After providing the correct values, the error message does not disappear immediately.

Navigation.tsx

async function handleNextStep() {
  if (step === 1) {
    const result = await form.trigger(["name", "email", "phone"], {
      shouldFocus: true,
    });
    result && setStep(2);
  }

  if (step === 2) {
    const result = await form.trigger("plan", { shouldFocus: true });
    result && setStep(3);
  }

  if (step === 3) {
    const result = await form.trigger("addOns", { shouldFocus: true });
    result && setStep(4);
    const values = form.getValues();
    setValues(values);
  }
}

Code
Loading...

Please log in to post a comment

Log in

Community feedback

No feedback yet. Be the first to give feedback on Shamim Ahsan’s solution.

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord