Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6102787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:39:17+00:00 2026-05-23T13:39:17+00:00

Does any one have sample code to apply phone number formatting to certain fields???

  • 0

Does any one have sample code to apply phone number formatting to certain fields??? I’m sort of a JS hack. Help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:39:18+00:00Added an answer on May 23, 2026 at 1:39 pm

    you should create a library and add the two methods below and then upload it as a web resource. Then assign the ‘OnPhoneFieldChange’ function to the Change event of each field you want to effect

        function OnPhoneFieldChange(context)
    {
        var value = context.getEventSource().getValue();
        if (typeof(value) != "undefined" && value != null)
        {
            value = formatPhoneNumber(value);   
        }
        context.getEventSource().setValue(value);
    }
    
    function formatPhoneNumber(inputValue) {
        var scrubbed = inputValue.toString().replace(/[^0-9]/g, "");
    
        var sevenDigitFormat = /^\(?([0-9]{3})[-. ]?([0-9]{4})$/;
        var tenDigitFormat = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
        var extDigitFormat = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})?([0-9]*)$/;
        if (tenDigitFormat.test(scrubbed)) {
            return scrubbed.replace(tenDigitFormat, "($1) $2-$3");
        }
        else if (sevenDigitFormat.test(scrubbed)) {
            return scrubbed.replace(sevenDigitFormat, "$1-$2");
        }
        else if (extDigitFormat.test(scrubbed)) {
            return scrubbed.replace(extDigitFormat, "($1) $2-$3 x$4");
        }
        return inputValue;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Visual Studio has a plugin that allows one to copy code from any editor
I have a webpage that takes 10 minutes to run one query against a
I'm still in need of help. I have website settings that I want to
I don't have any significant experience with C++ but recently had to be involved
I have a basic calculation function that I apply on each item in an
Similar questions have been asked before but after a day of going through the
I have a requirement where in i need to updated my widget once in
Okay, here's the situation. I have two NSManagedObjects called Store and Aisle . There
I want to do hierarchical agglomerative clustering on texts in MATLAB. Say, I have
http://developer.apple.com/library/ios/#samplecode/Touches/Introduction/Intro.html I'm new to IOS development, and have been playing around with the IOS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.