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
This client script adds a visual progress bar indicator when users type in text fields, showing how much of the field's maximum length has been used. It provides a more intuitive way to track character limits compared to simple numeric counters.
5
+
6
+
## Features
7
+
- Visual progress bar that updates in real-time
8
+
- Color-coded feedback (green, yellow, red) based on usage
9
+
- Percentage indicator alongside the progress bar
10
+
- Smooth transitions between states
11
+
- Works with any text field with a character limit
12
+
13
+
## Requirements
14
+
- ServiceNow instance
15
+
- Client Script execution rights
16
+
- Text fields with character limits (e.g., short_description, description)
17
+
18
+
## Implementation Steps
19
+
1. Navigate to System Definition → Client Scripts
20
+
2. Create a new Client Script with these settings:
21
+
- Table: Choose your target table (e.g., incident, sc_req_item)
22
+
- Type: onChange
23
+
- Field name: Your target field (e.g., short_description)
24
+
3. Copy the code from script.js into your client script
25
+
4. Configure the maxLength variable if needed
26
+
5. Save and test
27
+
28
+
## Configuration
29
+
The script can be customized by modifying these variables:
30
+
```javascript
31
+
var maxLength =160; // Maximum characters allowed
32
+
var warningThreshold =0.7; // Show yellow at 70% capacity
33
+
var criticalThreshold =0.9; // Show red at 90% capacity
34
+
```
35
+
36
+
## How It Works
37
+
1. The script creates a progress bar div element below the field
38
+
2. As the user types, it calculates the percentage of used characters
39
+
3. The progress bar fills proportionally to character usage
40
+
4. Colors change based on defined thresholds:
41
+
- Green: Normal usage
42
+
- Yellow: Approaching limit
43
+
- Red: Near/at limit
44
+
45
+
## Benefits
46
+
- Improved user experience with visual feedback
47
+
- Reduces likelihood of hitting character limits unexpectedly
48
+
- Helps users self-regulate content length
49
+
- Modern, professional appearance
50
+
- Zero server calls - all client-side
51
+
52
+
## Usage Example
53
+
When implementing on an Incident's short description:
0 commit comments