Aspen94 Zoho CRM Extension | Mobile Number Validation | Setup Guide

Aspen94 Zoho CRM Extension | Mobile Number Validation | Setup Guide

What This Extension Does

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:

  • Check if a mobile number is valid
  • Format it to (305) 123-4567
  • Show a message if something is wrong
  • Mark the number as Valid or Invalid

⚠ No coding experience needed — just follow the steps.


Step 1: Install the Extension

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.


Step 2: Configure the Twilio Credentials

Before configuring the extension, you need a Twilio account. If you don't have one yet:

  • Go to twilio.com and create a free account
  • After signing in, you'll be taken to the Twilio Console (main dashboard)
  • Locate the following credentials: Account SID and Auth Token
  • Copy and paste the Account SID and Auth Token values into the widget fields accordingly

🔒 Security: Your credentials are sensitive. Do not share them publicly. The extension stores them securely as org-level variables within Zoho CRM.


Step 3: Add Client Script

Now add the logic that checks the phone number.

  • In Setup, search for Client Script
  • Click Client Scripts
  • Click New Script

Configure the Script

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.


Step 4: Paste the Code

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" });
}

Step 5: Save the Client Script

Click Save to activate the validation.


Step 6: Repeat for All Pages and Modules

Repeat the same process for all relevant pages and modules:

Leads Module

  • Create Page (Standard)
  • Edit Page (Standard)
  • Clone Page (Standard)

Contacts Module

  • Create Page (Standard)
  • Edit Page (Standard)
  • Clone Page (Standard)

⚠ If your module has multiple layouts, repeat this configuration for each layout where the Mobile field is present.


What Happens Now?

When a user enters a mobile number, the following happens automatically:

Valid Number

  • Formatted automatically to (xxx) xxx-xxxx
  • A success message appears
  • Status = Valid

Invalid Number

  • An error message appears
  • The field is highlighted
  • Status = Invalid

Empty Field

  • A warning message appears
  • Status is cleared

Examples

Input Result
3051234567 (305) 123-4567
13051234567 (305) 123-4567
123 Invalid
(305)-123-4567 Cleaned & valid

Important Notes

  • This currently validates US phone numbers only
  • Runs instantly when users change the Mobile field
  • Does NOT affect existing records unless edited

Need help?

Toll Free: 866.880.4228 | Local: 734.455.7188
Email: zoho.support@aspen94.com | Web: aspen94.com