You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Client Script: Mandatory Field Highlighter using proper ServiceNow methods
- Highlights empty mandatory fields with error messages
- Uses g_form.showFieldMsg() and hideFieldMsg() instead of DOM manipulation
- Includes onLoad script for initial highlighting
- Includes onChange script for real-time updates
- Follows ServiceNow best practices and official APIs
Highlight mandatory fields that are empty by showing error messages, making it easier for users to identify which required fields need to be completed.
5
+
6
+
## Solution
7
+
Two client scripts that work together:
8
+
1.**onLoad script**: Shows error messages for empty mandatory fields when form loads
9
+
2.**onChange script**: Updates error messages in real-time as users fill fields
10
+
3. Uses proper ServiceNow methods instead of DOM manipulation
11
+
12
+
## Implementation
13
+
1. Create an **onLoad** client script with the code from `script.js`
14
+
2. Create an **onChange** client script with the code from `onChange.js`
15
+
3. Apply both scripts to the same table/form
16
+
17
+
## Files
18
+
-`script.js`: onLoad client script for initial highlighting
19
+
-`onChange.js`: onChange client script for real-time updates
20
+
21
+
## Notes
22
+
- Uses `g_form.showFieldMsg()` and `g_form.hideFieldMsg()` methods
23
+
- Follows ServiceNow best practices (no DOM manipulation)
24
+
- Works with standard ServiceNow forms
25
+
- Provides clear error messages for required fields
0 commit comments