Page 6 of 6 FirstFirst ... 23456
Results 51 to 52 of 52

Thread: Usability Enhancement: Phone Formatting

  1. #51
    amygrant is offline Sugar Community Member
    Join Date
    Dec 2011
    Posts
    13

    Default Re: Usability Enhancement: Phone Formatting

    Just wanted to let everyone know this still works like a champ in 6.3

    One problem I noticed however is if the field already had the an extension such as "(555) 555-5555 Ext 55", the onblur would change it to "(555) 555-5555 Ext Et55" and every time you lost focus on that field it would keep adding "Et"

    In phone_format.js on line 20 is
    Code:
    phone = phone.replace(/\s|\(|\-|\)|\.|x|:|\*/g, "");
    I see no use for not just stripping everything which is not numeric so I changed it to
    Code:
    phone = phone.replace(/\D/g,"");
    fixed the problem

  2. #52
    Dbbncv is offline Junior Member
    Join Date
    Sep 2011
    Posts
    1

    Lightbulb Re: Usability Enhancement: Phone Formatting 6.4

    It works on 6.4

    Here are the adjustments we made to work for North America ( +1 )

    Code:
    function fmt(num, id) {
    	var phone = num;
    	var pre = '';
    	var main = '';
    	var ext = '';
    
    	phone = phone.replace(/\D/g,"");
    
    	if (phone.length == 0) {
    		return false;
    	}
    	
    	if (phone.substr(0,1) == '1') {
    		area =  "+1 (" + phone.substr(1,3) + ") ";
    		pre = phone.substr(4,3) + "-";
    		main = phone.substr(7,4);
    		
    		if (phone.length > 11) {
    			ext = " Ext: " + phone.substr(11);
    			phone = area + pre + main + ext;
    		} else {
    			phone = area + pre + main;
    		}
    		
    	} else {
    		area = "+1 (" + phone.substr(0,3) + ") ";
    		pre = phone.substr(3,3) + "-";
    		main = phone.substr(6,4);
    
    		if (phone.length > 10) {
    			ext = " Ext: " + phone.substr(10);
    			phone = area + pre + main + ext;
    		} else {
    			phone = area + pre + main;
    		}
    	}

Page 6 of 6 FirstFirst ... 23456

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •