Available since v0.1.0
fs-trigger="change"
StableFires on the native change event, which varies subtly by control type:
- Text inputs and textareas:
changefires when the control loses focus AND its value has been modified since it was focused. Useinputif you want every keystroke. - Checkboxes and radios: fires every time the checked state flips.
- Select menus: fires every time a new option is selected.
Syntax
<input type="checkbox"
fs-assert="todos/toggle-complete"
fs-trigger="change"
fs-assert-updated=".todo-item[classlist=completed:true]">
When to use it
- Checkbox toggles, radio choices, select-menu changes — immediate feedback
- Final-value validation on a text input (use
blurif you want the focus event instead)
Example
<select
fs-assert="profile/change-plan"
fs-trigger="change"
fs-assert-updated="#plan-summary[text-matches=Pro|Enterprise]">
<option>Free</option>
<option>Pro</option>
<option>Enterprise</option>
</select>
Pairs well with
fs-assert-updated— the control's effect updates something in the pagefs-assert-visible— a dependent section appears after the change[checked=true]— verify the new checked state on the same element via self-referencing[value-matches=...]— verify the new value via self-referencing (form controls)- Dynamic assertion values — for bidirectional toggles, compute the expected next state in the template
Gotchas
- Text inputs don't fire
changeon every keystroke. Useinputfor per-keystroke evaluation. - The toggle-expected-next-state pattern. On a toggle, the assertion runs BEFORE the state flip completes visually in some frameworks. Compute
!currentStatein the attribute value so the assertion targets the post-toggle state.
See also
input— per-keystroke alternativeblur— trigger on focus loss regardless of value change- Triggers index