NuxtUI Form Submit Issue
I'm using NuxtUI and the
UForm element cannot be submitted. It says that e.preventDefault is not a function:
Here's a reproduction:

21 Replies
Hi @Wilson. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the provided knowledge sources, the NuxtUI
UForm component expects the @submit event handler to receive a FormSubmitEvent object, not a native DOM event. This object does not have a preventDefault method, which is why you see the error "e.preventDefault is not a function".
In your code, you are using an inline arrow function for the @submit event:
This is fine, but you should not expect e to be a native event. Instead, it is a form event object containing the submitted data. You do not need to call preventDefault—NuxtUI handles form submission and validation internally.
Here’s a correct example from the documentation:
Key points:
- The @submit handler receives a custom event, not a native event.
- You do not need to call preventDefault.
- Use a function that handles the form data as shown above.
This approach is consistent with the official NuxtUI documentation for form submission and validation handling NuxtUI Form Schema Validation.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@202249480148353025> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@Wilson can you try to put your UInput in a UFormField, with a "name" attribute
The validation of the form is using the name to display error message
from the zod validation
i tried that also. The issue is that the form event calls preventDefault somewhere in the Nuxt UI source code and it’s not a function and hence the type error.
if it’s the zod fault, then it shouldn’t have worked when i submit manually via a templateRef.
i think it’s probably a recent bug?
the bot is explaining (not really in detail but it's true) that calling a function inline, is also calling e.preventdefault by default, but, in the @submit of the UForm component, it's not a native event
The one used in UForm is a FormSubmitEvent that doesn't have the preventdefault method
no it's not recent
mb doing it inline is just to make the reproduction code as short as possible. However i don’t think declaring it as a separate function makes any difference
call it without the parentheses
that’s what i do it my code and same error
@submit="yourSubmitFunction" not @submit="yourSubmitFunction()"@kapa.ai I am also experiencing this issue of the form not submitting here is my code copiesd directly from docs:
Let me check the knowledge base for you again. One moment! :books:
----------------------
I can see a few issues in your code that might be preventing the form from submitting properly:
Issues in Your Code
1. Incorrect import path: You're importing
FormSubmitEvent from "@nuxtui/form", but based on the knowledge sources, it should be imported from "#ui/types" or "@nuxt/ui".
2. Incorrect Zod schema methods: You're using z.email() and passing strings directly to z.string(), but these are not valid Zod methods. The correct syntax should be:
- z.string() for strings (without arguments)
- .email() as a chained method for email validation
- Error messages should be passed as options objects
3. Missing button type: Your UButton doesn't have type="submit" specified, which is necessary for form submission.
Corrected Code
Based on the patterns shown in the knowledge sources, here's the corrected version:
The key changes are:
- Fixed the Zod schema syntax
- Added type="submit" to the UButton
- Corrected the import path for FormSubmitEvent
These corrections should resolve your form submission issue.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@332238302457495564> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
I see, uhm ..... @kapa.ai would this not work if i didnt have the typescript stuff?
Let me check the knowledge base for you again. One moment! :books:
----------------------
Based on the knowledge sources provided, I don't have specific information about whether NuxtUI forms work without TypeScript. However, I can provide some general guidance:
The TypeScript types (like
FormSubmitEvent<Schema> and type Schema = z.output<typeof schema>) are primarily for development-time type checking and IDE support. They don't affect runtime behavior.
What you can simplify without TypeScript:
What you still need:
1. The Zod schema (this is for runtime validation, not TypeScript)
2. The @submit handler function
3. type="submit" on your button
4. Proper Zod schema syntax
The form should work without the TypeScript type annotations, as long as you keep the Zod schema for validation and follow the correct event handling pattern. However, the knowledge sources don't explicitly confirm this, so I recommend testing it in your specific setup.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@332238302457495564> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai i spcifically mean this
handleSignUp(event: FormSubmitEvent<Schema>)Let me check the knowledge base for you again. One moment! :books:
----------------------
Yes, you can remove the TypeScript type annotation from the function parameter. The type annotation
event: FormSubmitEvent<Schema> is purely for TypeScript's type checking and doesn't affect runtime behavior.
Without TypeScript:
This will work exactly the same at runtime. The event parameter will still contain the form data in event.data, you just won't get TypeScript's autocomplete and type checking in your IDE.
The important parts that must remain:
1. The function must accept an event parameter (even without the type)
2. You access the submitted data via event.data
3. The function is passed to @submit="handleSignUp"
The TypeScript types are only for development-time assistance—they get stripped away during the build process and don't affect how the code actually runs.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@332238302457495564> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai how would i access the values submitted from this from, currently the console log returns this:
Let me check the knowledge base for you again. One moment! :books:
----------------------
Based on the knowledge sources, the
event.data you're receiving is a reactive Proxy object. To access the actual values, you need to use .value or access the properties directly from the Proxy.
From the knowledge sources, when working with reactive data from useFetch and similar composables in Nuxt, the data is wrapped in a ref, and you access it using .value.
To access the submitted form values:
The Proxy object you're seeing is Vue's reactivity system at work. You don't need to unwrap it with .value in this case—you can access the properties directly from event.data as shown above.
If you need a plain JavaScript object without the Proxy wrapper, you can use toRaw() from Vue:
This is demonstrated in the knowledge sources where toRaw() is used to convert reactive state to a normal object.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@332238302457495564> Kapa.ai is still learning and improving, please let me know how I did by reacting below.