Jam.py documentation

on_field_validate

on_field_validate(field)

domain: client

language: javascript

class Item class

Description

Write an on_field_validate event handler to validate changes made to the field data.

The field parameter is the field whose data has been changed. To get the item that owns the field, use the owner attribute of the field.

The event handler must return a string if the field value is invalid. When an event handler returns a string, the application throws an exception.

The event is triggered when the post method is called or when the user leaves the input used to edit the field value.

Example

function on_field_validate(field) {
    if (field.field_name === 'sum' && field.value > 10000000) {
            return 'The sum is too big.';
    }
}