Users enter or modify the value of data fields in Docuo from the details window of a document, or from web forms.
To facilitate data entry, when a field is created, the type of content it will have is configured: Date, number, currency, text, drop-down lists, etc.
However, sometimes, it is necessary to carry out a stricter control of what users can enter in a field.
Restricting the format of a field by means of a regular expression
A first option is to set a Format, a strict restriction on what a user can enter, configured from what are known as regular expressions.
Use the “Behavior – Format” option to set up a regular expression in a field to validate what the user enters:
However, in some scenarios, rather than restricting what the user enters, what needs to be done is to analyze and modify it, either in the same field or in other fields.
Execute a Script when a user changes the value of a field
The event “When changing the value” of the options of a data field, allows to write a code fragment in JavaScript language, which will be executed in the editing screen (details window or form) when the user types the text and validates it, typically by leaving the focus of the control (by pressing the tab key for example or clicking elsewhere with the mouse).
The JavaScript code you write here can use proprietary functions such as uiSetFieldValue, which allow you to MODIFY the contents of the field you are typing in, or even other fields:
This allows, for example, setting the first letter to uppercase when the user enters a proper name, parsing, splitting and separating the entered information and taking it to different fields, or simply validating the composition of what the user types with JavaScript and returning an explanatory error message.