The Mobile Number Validation extension uses a Zoho CRM Client Script with regex pattern matching to validate, format, and flag US mobile numbers in real time as users enter them on Lead and Contact records.
This guide will help you automatically:
⚠ No coding experience needed — just follow the steps.
Use the installation link provided by your Aspen94 consultant. Contact us at zoho.support@aspen94.com if you have any questions or need any information.
Before configuring the extension, you need a Twilio account. If you don't have one yet:
🔒 Security: Your credentials are sensitive. Do not share them publicly. The extension stores them securely as org-level variables within Zoho CRM.
Now add the logic that checks the phone number.
Fill in the form with the following values:
| Setting | Value |
|---|---|
| Name | Regex Validation for Mobile |
| Description | Validation for Mobile field using Regex function. |
| Category | Module |
| Page | Create Page (Standard) |
| Module | Leads (or Contacts) |
| Layout | Standard |
| Event Type | Field Event |
| Field | Mobile |
| Trigger | onChange |
ℹ If all fields are not visible initially, begin filling in the available fields. The remaining sections will appear automatically.
Click Next to continue.
Copy and paste the following code into the script editor:
// Name: Regex Validation for Mobile
// Event Type: Field Event | Field: Mobile | Event: onChange
// 1. Get field values
let mobileField = ZDK.Page.getField('Mobile');
let statusField = ZDK.Page.getField('asphen94__Mobile_Status');
let mobile_value = (mobileField.getValue() || "").trim();
let mobile_status_value = statusField.getValue();
// If empty → reset and stop
if (!mobile_value) {
statusField.setValue("");
ZDK.Client.showMessage("Mobile is empty", { type: "warning" });
return;
}
try {
// Declare statusText
let statusText = "";
// 2. Normalize (remove all non-digits)
let cleaned = mobile_value.replace(/\D/g, "");
// Remove leading "1" if 11 digits (US country code)
if (cleaned.length === 11 && cleaned.startsWith("1")) {
cleaned = cleaned.substring(1);
}
// 3. Validate (US NANP rules)
const isValid = /^[2-9][0-9]{2}[2-9][0-9]{6}$/.test(cleaned);
if (isValid) {
statusText = "Valid";
// 4. Format → (XXX) XXX-XXXX
const formatted = `(${cleaned.substring(0,3)}) ${cleaned.substring(3,6)}-${cleaned.substring(6)}`;
if (mobile_value !== formatted) { mobileField.setValue(formatted); }
ZDK.Client.showMessage("Valid US mobile number", { type: "success" });
} else {
statusText = "Invalid";
ZDK.Client.showMessage("Please enter a valid 10-digit US mobile number", { type: "error" });
mobileField.showError('Invalid value');
}
// 5. Update status field (only if changed)
if (mobile_status_value !== statusText) { statusField.setValue(statusText); }
} catch (error) {
log("Validation error", error);
statusField.setValue("Error");
ZDK.Client.showMessage("Error validating phone number", { type: "error" });
}Click Save to activate the validation.
Repeat the same process for all relevant pages and modules:
⚠ If your module has multiple layouts, repeat this configuration for each layout where the Mobile field is present.
When a user enters a mobile number, the following happens automatically:
| Input | Result |
|---|---|
3051234567 |
(305) 123-4567 |
13051234567 |
(305) 123-4567 |
123 |
Invalid |
(305)-123-4567 |
Cleaned & valid |
Need help?
Toll Free: 866.880.4228 | Local: 734.455.7188
Email: zoho.support@aspen94.com | Web: aspen94.com