Available since v0.1.0
fs-trigger="submit"
StableFires on the native submit event — place it on the <form> element. A capture-phase listener means the agent sees the submit even if a framework or library calls preventDefault() later (HTMX, for instance, suppresses the native submit after its listeners run).
Syntax
<form
fs-assert="contact/submit-form"
fs-trigger="submit"
fs-assert-visible=".success-message">
<input name="email" type="email" />
<button type="submit">Send</button>
</form>
When to use it
- Form submissions — the canonical choice over
clickon the submit button - Any
<form>whose submit semantics matter for correctness
Either fs-trigger="submit" on the form OR fs-trigger="click" on the submit button works. Pick the one that reads clearer for your markup. Don't use both on the same assertion key — you'll get two fires per submit.
Example
<form
fs-assert="signup/create-account"
fs-trigger="submit"
fs-assert-mutex="each"
fs-assert-visible-success=".welcome-dashboard"
fs-assert-added-error=".form-errors">
…
</form>
Pairs well with
- Conditional assertions —
success/validation-error/server-errorbranches fs-assert-mutex="each"— group cross-type conditionalsfs-assert-timeout— network operations deserve an explicit SLAfs-assert-mpa="true"— persist the assertion across a full page navigation
Gotchas
- Enter-to-submit bypasses the submit button. If you put the trigger on the button instead of the form, pressing Enter inside a text field submits the form without firing the click handler. Prefer
submiton the form to cover both paths. - AJAX submits via
preventDefault. Capture listeners see the event first, so the assertion still fires even when JS prevents the real submission.
See also
click— alternative placement on the submit button- Patterns cookbook #6
- Triggers index