US Phone Number Validation Script

US Phone Number Validation Script is use to validate US telephone number through regular expression.

Demo :



Telephone number :    

Example :

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

Code :

Following code is use to US Phone Number Validation Script if you need to copy and use to your website.


<?php
function validateUSPhone($str)
{
  return preg_match("/^[2-9]\d{2}-\d{3}-\d{4}$/", $str);
}
  $us_phone_no = "301-111-1111";
  echo validateUSPhone($us_phone_no) ? "Is a properly-formatted US phone number" : "Is an improperly-formatted US phone number";
?>

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

Free Download Script :

If you need to US Phone Number Validation Script click and download from following link.

Download




Content