+ Start a Discussion
Arc30Arc30 

How to validate a phone number in contacts page by using custom button

Hi

In a contact page i need to get the country code of the given number
i have created a custom button by using on click execute java script to validate the phone number
Kindly let me know how to solve

Thanks
 
PratikPratik (Salesforce Developers) 
Hi Archith,

Please share the code that you have written  for the custom button so we can help.

Thanks,
Pratik
Arc30Arc30
hi Pratik

please find the following. i have commented in few places. Kindly suggest me

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}
{!REQUIRESCRIPT("/resource/demophone")}
 

var phone=document.getElementById('{!Contact.PersPhone__c}_lkid').value;
alert($innerHTML);

/*var updateRecord = new Array();
var myquery =" select countrycode__c, from contact where id='{! Contact.Id}' ";
var records = sforce.connection.query(result );
var records1 = records.getArray('records');
alert(records);

<script>
    var gNewCountryCode = "";
    var gPossibleNumber = "";
    var gValidNumber = "";
    var gNumberType = "";
    function fnOnClick()
    {
        gNewCountryCode = "";
        gPossibleNumber = "";
        gValidNumber = "";
        gNumberType = "";
    
        document.getElementById("NewDisplayID").style.display="none";
        
        phoneNumberParser();
        
        document.getElementById("NewDisplayID").style.display="block";
        document.getElementById("NewInformationID").innerHTML = "";
        
        if(gNewCountryCode != "")
        {
            document.getElementById("NewInformationID").innerHTML = "This Country Code is " + gPossibleNumber + " " + gValidNumber + " " + gNewCountryCode + " " + gNumberType ;
        }
        else
        {
            document.getElementById("NewInformationID").innerHTML = "This is not valid Country Code";
        }
    }
    
    function fnClose()
    {
        document.getElementById("NewDisplayID").style.display="none";
    }
</script>
*/