================= on_field_validate ================= on_field_validate(field) **domain**: client **language**: javascript **class** :doc:`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 :doc:`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 :doc:`post ` method is called or when the user leaves the input used to edit the field value. Example ======= .. code-block:: js function on_field_validate(field) { if (field.field_name === 'sum' && field.value > 10000000) { return 'The sum is too big.'; } } See also ======== :doc:`Fields ` :doc:`value ` :doc:`How to validate field value `