Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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, '');
}
}
Loading