Skip to content

Commit 3011062

Browse files
Create Readme.md
1 parent b8f45a2 commit 3011062

File tree

1 file changed

+46
-0
lines changed
  • Client-Side Components/Client Scripts/validate phone number

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Phone Number Validation — Client Script (ServiceNow)
2+
Overview
3+
4+
This Client Script ensures that users enter their phone numbers in a strict format: (123) 456-7890.
5+
It is triggered whenever the Phone field changes and validates the input in real time.
6+
7+
If the input does not match the required format, the script:
8+
9+
Clears the invalid value.
10+
11+
Displays a field-level error message directly below the field.
12+
13+
Provides a fallback alert if field-level messaging is unavailable.
14+
15+
This script is designed to be user-friendly, dynamic, and failsafe.
16+
17+
Features
18+
19+
Validates phone numbers in the format (123) 456-7890.
20+
21+
Inline error messages appear directly below the field, avoiding top-of-page clutter.
22+
23+
Clears invalid input to prevent incorrect data submission.
24+
25+
Works dynamically for any phone field with minimal configuration.
26+
27+
Provides fallback alert for environments where inline messages are unavailable.
28+
29+
Usage Instructions
30+
1. Create the Client Script
31+
32+
Navigate to System Definition → Client Scripts.
33+
34+
Click New to create a client script.
35+
36+
2. Configure the Script
37+
38+
Name: Phone Number Validation
39+
40+
Table: sys_user
41+
42+
Type: onChange
43+
44+
Field: phone
45+
46+
Active: Checked

0 commit comments

Comments
 (0)