Available since v0.1.0

fs-trigger="change"

Stable

Fires on the native change event, which varies subtly by control type:

  • Text inputs and textareas: change fires when the control loses focus AND its value has been modified since it was focused. Use input if 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 blur if 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

Gotchas

  • Text inputs don't fire change on every keystroke. Use input for 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 !currentState in the attribute value so the assertion targets the post-toggle state.

See also