Validate Telephone Number Script

Validate Telephone Number Script is use to validate telephone number through regular expression.

Demo :



Telephone number :    

Example :

Just type a proper international phone number like this +1 301 111 1111 and click check button Is a properly-formatted phone number message will display otherwise type a 12346 number at textbox and click check button improperly-formatted phone number will display here.

Code :

Following code is use to Validate Telephone Number Script if you need to copy and use to your website.


<?php
function validateIntlPhone($str)
{
  return preg_match("/^(\+|00)[1-9]{1,3}(\.|\s|-)?([0-9]{1,5}(\.|\s|-)?){1,3}$/", $str);
}
  $phone_number = "+1 301 111 1111";
  echo validateIntlPhone($phone_number) ? "Is a properly-formatted phone number" : "Is an improperly-formatted phone number";
?>

In the above $phone_number variable is use to assign the Phone Number. In the validateIntlPhone() function is use to check the validate telephone number through regular expression.

Free Download Script :

If you need Validate Telephone Number Script click and download from following link.

Download




Content