Events
Events
Trivule provides the ability to listen for different JavaScript events to trigger form validation without writing additional JavaScript code. This increases flexibility and simplifies form validation management.
Triggering Validation with Default Events
By default, Trivule uses the blur, and change events to trigger form field validation. This means that whenever a user enters, leaves, or modifies a value in a form field, validation is automatically triggered.
For instance, if you want to trigger validation when an element is hovered over by the mouse cursor, you can use Trivule's @v:events attribute and specify the mouseenter event as follows:
<input @v:events="input" />The @v:events attribute can also accept a list of events (input|blur|submit) separated by the | (pipe) symbol. For example, you can use the input event to trigger validation whenever a field changes.
<input @v:events="input|blur|submit" />