From 0b558c5b1862cb1d1bcd0a8bdeb2a4021a7c2d22 Mon Sep 17 00:00:00 2001 From: Sachin Narayanasamy <132642563+SachinNarayanasamy@users.noreply.github.com> Date: Tue, 21 Oct 2025 15:50:17 +0530 Subject: [PATCH 1/4] Create Validate PhNo.js --- .../validate phone number/Validate PhNo.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Client-Side Components/Client Scripts/validate phone number/Validate PhNo.js diff --git a/Client-Side Components/Client Scripts/validate phone number/Validate PhNo.js b/Client-Side Components/Client Scripts/validate phone number/Validate PhNo.js new file mode 100644 index 0000000000..9a293deb03 --- /dev/null +++ b/Client-Side Components/Client Scripts/validate phone number/Validate PhNo.js @@ -0,0 +1,23 @@ +function onChange(control, oldValue, newValue, isLoading) { + if (isLoading || !newValue) return; + + var fieldName = control.name; + + // Split the string + var area = newValue.substring(1, 4); + var firstThree = newValue.substring(6, 9); + var lastFour = newValue.substring(10, 14); + + if ( + newValue[0] !== '(' || newValue[4] !== ')' || newValue[5] !== ' ' || newValue[9] !== '-' || + isNaN(parseInt(area)) || isNaN(parseInt(firstThree)) || isNaN(parseInt(lastFour)) + ) { + g_form.showFieldMsg( + fieldName, + 'Phone Number must be in the format (123) 456-7890', + 'error', + false + ); + g_form.setValue(fieldName, ''); + } +} From 0998d9e2e1635453eeb6d256c5e9ec6c09a388a6 Mon Sep 17 00:00:00 2001 From: Sachin Narayanasamy <132642563+SachinNarayanasamy@users.noreply.github.com> Date: Tue, 21 Oct 2025 15:51:25 +0530 Subject: [PATCH 2/4] Create Readme.md --- .../validate phone number/Readme.md | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Client-Side Components/Client Scripts/validate phone number/Readme.md diff --git a/Client-Side Components/Client Scripts/validate phone number/Readme.md b/Client-Side Components/Client Scripts/validate phone number/Readme.md new file mode 100644 index 0000000000..5f47923199 --- /dev/null +++ b/Client-Side Components/Client Scripts/validate phone number/Readme.md @@ -0,0 +1,39 @@ +Phone Number Validation — Client Script +Overview + +This Client Script validates that users enter their phone numbers in the strict format: (123) 456-7890. + +It is triggered whenever the Phone field changes on a sys_user record. If the input does not match the required format, the script: + +Displays an inline error message directly below the field. + +Clears the invalid input so the user can re-enter the correct value. + +This script is designed to be dynamic, simple, and user-friendly. + +Features + +Ensures phone numbers follow the exact format (123) 456-7890. + +Provides immediate feedback via field-level error messages. + +Clears invalid entries automatically to prevent submission errors. + +Works on Classic UI forms and provides clear messaging to the user. + +Usage Instructions +1. Create the Client Script + +Navigate to System Definition → Client Scripts. + +Click New to create a client script. + +2. Configure the Script + +Name: Phone Number Validation + +Table: sys_user + +Type: onChange + +Field: phone From 506767c9e8ff4a3c14577a47144ed8b50fc80930 Mon Sep 17 00:00:00 2001 From: Sachin Narayanasamy <132642563+SachinNarayanasamy@users.noreply.github.com> Date: Tue, 21 Oct 2025 16:17:06 +0530 Subject: [PATCH 3/4] Rename Validate PhNo.js to validate_phone_format_(123)_456-7890_no_regex.js.js --- ...hNo.js => validate_phone_format_(123)_456-7890_no_regex.js.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Client-Side Components/Client Scripts/validate phone number/{Validate PhNo.js => validate_phone_format_(123)_456-7890_no_regex.js.js} (100%) diff --git a/Client-Side Components/Client Scripts/validate phone number/Validate PhNo.js b/Client-Side Components/Client Scripts/validate phone number/validate_phone_format_(123)_456-7890_no_regex.js.js similarity index 100% rename from Client-Side Components/Client Scripts/validate phone number/Validate PhNo.js rename to Client-Side Components/Client Scripts/validate phone number/validate_phone_format_(123)_456-7890_no_regex.js.js From 5102dd488cfa9af13cf6ac7fb0e087fbf36e6606 Mon Sep 17 00:00:00 2001 From: Sachin Narayanasamy <132642563+SachinNarayanasamy@users.noreply.github.com> Date: Tue, 21 Oct 2025 16:18:23 +0530 Subject: [PATCH 4/4] Update validate_phone_format_(123)_456-7890_no_regex.js.js Validates a field to ensure no spaces and enforces the phone number format (123) 456-7890 without using regex. Displays an inline error message below the field and clears invalid input for strict, user-friendly data entry.