Skip to content

Commit 4a57bfc

Browse files
authored
Create README.md
1 parent e973eae commit 4a57bfc

File tree

1 file changed

+5
-0
lines changed
  • Client-Side Components/Client Scripts/Display a Live Word Count for Description Field

1 file changed

+5
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The script enhances a form field (specifically the description field) by:
2+
-Adding a live word counter below the field.
3+
-Visually warning the user if the word count exceeds 150 words.
4+
5+
This client-side script, intended for use in a ServiceNow form (e.g., catalog item or incident form), dynamically appends a custom `<div>` element below the `description` field to display a real-time word count. It leverages the `g_form.getControl()` API to access the field's DOM element and attaches an `input` event listener to monitor user input. The script calculates the word count by splitting the input text using a regular expression (`\s+`) and updates the counter accordingly. It applies conditional styling to the counter (`green` if ≤150 words, `red` if >150), providing immediate visual feedback to the user to enforce input constraints.

0 commit comments

Comments
 (0)