+ Start a Discussion
prabhakar r 3prabhakar r 3 

code for mobile no. format

giving the code for mobile format- 999-999-9999
SonamSonam (Salesforce Developers) 
I understand you are looking for code to validate a hone number being entered, please check the blog on the link below :http://sfdc2u.blogspot.sg/2013/08/phone-number-validation-in-salesforce.html
Venkata Sravan Kumar BandariVenkata Sravan Kumar Bandari
if (phone != null)  
        {  
              Pattern phonePattern = Pattern.compile('\\D*?(\\d\\D*?){10}');  
              Pattern numericPattern = Pattern.compile('[0-9]{10}');  
              Matcher phoneMatcher = phonePattern.matcher(phone);  
              
        if(phone.length() == 10)  
        {  
              Matcher numericMatcher = numericPattern.matcher(phone);  
              if(!numericMatcher.matches())  
                  ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Invalid Phone Number')); 
              else
                  ApexPages.addMessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Your phone number is valid: '+phone));
        }
        else 
              ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Invalid Phone Number'));
        }

Hope it helps..
If yes select this as best answer...Thank u