Display field messages
- UpdatedAug 3, 2023
- 2 minutes to read
- Vancouver
- Building applications
Rather than use JavaScript alert(), for a cleaner look, you can display an error on the form itself. The methods showFieldMsg() and hideFieldMsg() can be used to display a message just below the field itself.
showFieldMsg and hideFieldMsg are methods that can be used with the g_form object.
These methods are used to change the form view of records (Incident, Problem, and Change forms). These methods may also be available in other client scripts, but must be tested to determine whether they work as expected.
When a field message is displayed on a form on load, the form scrolls to ensure that the field message is visible. Ensuring that users do not miss a field message because it was off the screen.
The global property glide.ui.scroll_to_message_field controls automatic message scrolling when the form field is offscreen (scrolls the form to the control or field).
Method Detail | Parameters | Example |
---|---|---|
showFieldMsg(input, message, type, [scrollform]) |
|
Error Message Informational Message |
hideFieldMsg(input) |
|
Removing a Message |
Legacy support
The showErrorBox() and hideErrorBox() are still available but simply call the new methods with type of error. You should use the new methods.