--- includeMockServer: true title: "Reset on Submit" description: Clear form inputs after submission icon: "icon-[mdi--eraser]" ---
## Basic usage On the client, wrap your inputs in a `
` and use [`hx-on`](/reference/attributes/hx-on) to reset it after each successful request. ```html
``` - [`hx-post`](/reference/attributes/hx-post) submits the form to `/chat`. - [`hx-target`](/reference/attributes/hx-target) points at the `#messages` container. - [`hx-swap`](/reference/attributes/hx-swap)=[`"beforeend"`](/reference/attributes/hx-swap#beforeend) appends each new message to the bottom. - [`hx-on:htmx:after:request`](/reference/attributes/hx-on) listens for the [`htmx:after:request`](/reference/events/htmx-after-request) event and calls `this.reset()` to clear the form. On the server, respond with the new message: ```html
Hello!
Hi there! How can I help?
``` ## Notes ### Without a form element The `reset()` method is only available on `
` elements. For standalone inputs, select the element and clear its value directly: ```html ``` - [`hx-include`](/reference/attributes/hx-include) tells the button which input to include in the request, since it is outside the button element.