AnsweredAssumed Answered

How to change phone format in international format like +x (xxx) xxx-xxxx

Question asked by Sanjeev Mallik on May 27, 2016

Hi

 

Here is the solution I found

 

file location : custom/clients/base/fields/phone/phone.js

 

 

({

extendsFrom:"PhoneField",

initialize:function(options)

{

     this._super("initialize",[options]);

     },

     format:function(value)

     {

         if((this.action==='list'||this.action==='detail'||this.action==='record')

             &&this.isSkypeFormatted(value)

             &&this.skypeEnabled)

     {

         this.skypeValue=this.skypeFormat(value);

         }

         if(!_.isEmpty(value)){if(value.length>=10){if(value.indexOf('-')==-1)

         {

            // value=value.substr(0,3)+'-'+value.substr(3,3)+'-'+value.substr(6,4);

             value='+1'+'('+value.substr(0,3)+')'+'-'+value.substr(3,3)+'-'+value.substr(6,4);

             }

        }

    }

             return value;

            

    }

})

 

Thank you

Outcomes