This below code will help you to validate phone number. (e.g. from form submit).

### Validate country code, area code and phone number

 $intisd=$_POST["txtcountrycode"];
 $intccode=$_POST["txtareacode"];
 $intphone=$_POST["txtphone"];

if(substr_count($intisd,"+")>0){
 if(strpos($intisd,"+")==0)
 $intisd=substr($intisd,1,strlen($intisd));
 }

if($intisd != NULL){
 $result=ereg("^[0-9]+$",$intisd,$trashed);
 $result=ereg("^[0-9]+$",$intisd,$trashed);
 if(!($result)){$errors[] = "Please enter valid country code.";}
 }
 if($intccode != NULL){
 $result=ereg("^[0-9]+$",$intccode,$trashed);
 if(!($result)){$errors[] .= "Please enter valid area code.";}
 }
 if($intphone != NULL){
 $result=ereg("^[0-9]+$",$intphone,$trashed);
 if(!($result)){$errors[] .= "Please enter valid phone number.";}
 }
 

Leave a reply

required

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>