Trigger Plugin
Attaches DOM event listeners to form fields and triggers validation when they fire.
Options
| Option | Type | Default | Description |
|---|---|---|---|
event | string | Record<string, string | false> | "input" | DOM event name(s) to listen to. Use a record to set per-field events. Set to false to disable a field. |
delay | number | 0 | Debounce delay in milliseconds before triggering validation |
Playground
Debouncing
Use delay to avoid validating on every keystroke — the timer resets with each event and validation only fires after the user stops typing:
js
new Trigger({ event: 'input', delay: 300 })You can combine different events and a delay:
js
new Trigger({
event: { email: 'blur', username: 'input' },
delay: 400, // applies to all fields
})blur events rarely need a delay — validation on blur fires once when the user leaves the field. Debounce is most useful with input and change.
Notes
- Without
Trigger, validation only runs when you callfv.validate()orfv.validateField()manually. - Events are attached on
core.field.addedand cleaned up oncore.field.removed. - For remote validators that make network requests, always set a
delayto avoid a request per keystroke.