Skip to content

Commit 634bfe6

Browse files
authored
Merge branch 'ServiceNowDevProgram:main' into Set-and-Lock-Variable-by-group
2 parents 787c1a2 + 2fa512a commit 634bfe6

File tree

160 files changed

+5683
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+5683
-266
lines changed

Client-Side Components/Catalog Client Script/Allow 10digit Fax Number/Allow 10digit Fax Number.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

Client-Side Components/Catalog Client Script/Allow 10digit Fax Number/README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

Client-Side Components/Catalog Client Script/Regex Validation/script.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

Client-Side Components/Catalog Client Script/Special Characters/README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

Client-Side Components/Catalog Client Script/Special Characters/script.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

Client-Side Components/Catalog Client Script/Strong Username Validation Script/README.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

Client-Side Components/Client Scripts/Allow positive and decimal values/Allow positive and decimal values.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

Client-Side Components/Client Scripts/Allow positive and decimal values/readme.md

Lines changed: 0 additions & 7 deletions
This file was deleted.
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.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
2+
if (isLoading || newValue === oldValue) {
3+
return;
4+
}
5+
6+
var wordCount = newValue.trim().split(/\s+/).length;
7+
var message = 'Word Count: ' + (newValue ? wordCount : 0);
8+
var messageType = (wordCount > 150) ? 'error' : 'info';
9+
10+
g_form.showFieldMsg('description', message, messageType);
11+
}

0 commit comments

Comments
 (0)