On Validate
Last updated 27/03/2026
Overview
The On Validate event is a client-side event that executes after a user has entered data into a field and then leaves the field. This allows the application to check whether the data is valid before the user continues. If the data is invalid, Five will create an error and force the user to correct the input before moving on.
How it Works
When a user leaves a field:
- The field loses focus.
- The On Validate event executes.
- Any validation logic associated with the field runs after the user has finished entering data.
- If the validation fails, the user is forced to correct the input before moving on.
Use Cases
- Ensure that a field's value meets required conditions
- Prevent saving or submitting invalid data
Example
This function executes when the user leaves the Quantity field and ensures the value is greater than 9.
Validate quantity
function ValidateQuantity(five, context, result) {
if (five.field.Quantity <= 9) {
return five.createError("Quantity must be greater than 9");
}
return five.success(result);
}