You need to sign in to do that
Don't have an account?

Reformat a phone number to just integers
Hello,
I have a simple VF page that passes the Lead phone number to our VoIP server but I need to strip the numbers of special characters that are sometimes present.
for instance;
user entered (508) 457-5100
I need to change it to 5084575100
or they could of done it any number of ways. Like 508-457-5100 or 508 457 5100 or 1800+656+6555 etc.
I know that that I have to create a loop that goes character by character to check to see if each character is a an integer or not . . . something like . . . onblur="this.value=this.value.replace(/[^\d]/g,'');" />
Would it be better to use the Apex code in the Controller for the VF page and then call on it or can I place it directly in the <script> that passes the phone number, ext, username?
Thanks for your help.
crmzepher
This is how I did it...
String getFax = jobQuote.Job__r.Customer__r.fax__c;
String areaCode = getFax.substring(1,4);
String localCode = getFax.substring(6,9);
String houseCode = getFax.substring(10,14);
getFax = areaCode + localCode + houseCode;
you could then convert the string to an integer
Integer i;
i = integer.valueof(getFax);