Next.js Discord

Discord Forum

Form Not submitting with an unknown error

Unanswered
Skipjack tuna posted this in #help-forum
Open in Discord
Skipjack tunaOP
I am using Zod, react-hooks-form and Next js 15 and Shadcn for my Submission Form i am facing the issue

As i am clicking the button its not submitting but when i add a blank space after the 2nd answer for each question it submits the form there no error and also when i console log the button click it detects but when i console log form submission it never triggers

30 Replies

Skipjack tunaOP
Skipjack tunaOP
Anyone know this issue??
Eastern Carpenter bee
Why are you using new FormData?, you don't need it
Rose-breasted Grosbeak
Submit even is usually not triggered when there's an invalid field
Try to see if that's the issue
https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/checkValidity

Or otherwise it could be zod/RHF preventing a successful event
Another common issue I remember (with formik) was when I forgot to include "name" in all the required places
what should i use?
@Rose-breasted Grosbeak Submit even is usually not triggered when there's an invalid field
Skipjack tunaOP
but i problem it when i just add a empty space it works
which doesnt make any sense
Eastern Carpenter bee
Nothing, submit return object values
Skipjack tunaOP
see the video
@Skipjack tuna but i problem it when i just add a empty space it works
Rose-breasted Grosbeak
Yes that's what you're supposed to debug
@Rose-breasted Grosbeak Yes that's what you're supposed to debug
Skipjack tunaOP
I am not getting the answer after endless debuging
as if some hidden stuff blocking the event
Dwarf Hotot
show the for code
Rose-breasted Grosbeak
That's exactly what I said
@Dwarf Hotot show the for code
Skipjack tunaOP
for code?
Dwarf Hotot
yes show code
Rose-breasted Grosbeak
No, something is preventing a submit event.
It's either the native form, or zod/rhf

In the later case, the submit event would be firing, just your function wouldn't run
@Skipjack tuna https://pastebin.com/nFQBxna7
Skipjack tunaOP
@Dwarf Hotot its a very big code so i used pastebin
Rose-breasted Grosbeak
Remove validation completely
@Rose-breasted Grosbeak Remove validation completely
Skipjack tunaOP
Zod is blocking as this but
When i already filled the form
Dwarf Hotot
<Form {...zohoForm}>
<form
onSubmit={zohoForm.handleSubmit(onSubmitZohoForm)}
className="w-full mt-3"
>
<div className="grid grid-cols-1 gap-2 fetch_country">
<FormField
control={zohoForm.control}
name="name"
render={({ field }) => (
<FormItem>
<FormControl>
<div className="flex items-center border border-gray-200 rounded-lg px-2 2xl:py-1">
<User color="black" className="w-[20px] h-[20px]" />
<Input
type="text"
placeholder="Name *"
className="focus-visible:ring-0 border-none focus:ring-0 bg-none outline-0 focus-visible:ring-offset-0"
{...field}
/>
</div>


handle form like this
Dwarf Hotot
yes
"use client";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { useEffect, useState } from "react";
import { Button } from "../ui/button";
import Image from "next/image";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "../custom/custom-select";
import {
Form,
FormControl,
FormField,
FormItem,
FormMessage,
} from "@/components/ui/form";