## Demo: form-cancel
### FormCancel.svelte
```svelte
The action sleeps 3 s to simulate a slow lookup. Each variant below uses the same action but cancels at a different point — or not at all.
The
The Without JavaScript there is nothing to cancel. The browser POSTs and waits the full 3 s, then the page re-renders with the result.cancel() — pre-flight short-circuitsubmit callback receives cancel. Calling it skips the fetch entirely — no request is sent, no result callback runs. Use this for client-side
validation or any condition you can check before leaving the browser.
controller.abort() — in-flight cancellationsubmit callback also receives an
AbortController. Calling controller.abort()
stops a fetch that has already started. Here a 1.5 s timeout aborts the 3 s lookup; enhance swallows the AbortError and resets the form to idle.
Plain HTML — no
enhance
{label}
{#if result}{result}
{/if} {#if message} {/if}{label}
{#if result}{result}
{/if} {#if message} {/if}{label}
{#if initialResult}{initialResult}
{/if} {#if initialMessage} {/if}