# handleSubmit

> This document is the Markdown version of [formisch.dev/methods/api/handleSubmit/](https://formisch.dev/methods/api/handleSubmit/). For the complete documentation index, see [llms.txt](https://formisch.dev/llms.txt).

Creates a submit event handler for the form that prevents default browser submission, validates the form input, and calls the provided handler if validation succeeds. This is designed to be used with the form's onsubmit event.

```ts
const result = handleSubmit<TSchema>(form, handler);
```

> In React Native, where there is no form element or submit event, `handleSubmit` returns a plain async function that you call from a button's `onPress` or a text input's `onSubmitEditing` handler. In this case the handler receives only the validated form output — there is no event object.

## Generics

- `TSchema` `extends FormSchema`

## Parameters

- `form` `BaseFormStore<TSchema>`
- `handler` `SubmitHandler<TSchema> | SubmitEventHandler<TSchema>`

### Explanation

The `form` parameter is the form store to handle submission for. The `handler` parameter can be a `SubmitHandler` (no event) or, in the frameworks that submit through a form element, a `SubmitEventHandler` (with event) that gets called with the validated form output if validation succeeds. In React Native only `SubmitHandler` applies, as there is no submit event.

## Returns

- `result` `(() => Promise<void>) | ((event: SubmitEvent) => Promise<void>)`

## Related

### Primitives

[`useForm`](/react/api/useForm.md)

### Methods

[`validate`](/methods/api/validate.md), [`focus`](/methods/api/focus.md), [`submit`](/methods/api/submit.md)
