validate the number in numeric format

<?php
function PhoneCheck($number)
{
return preg_match(”/^[(\[]?\d{3}[)-\.\] ]*\d{3}[-\. ]?\d{4}$/”, $number, $scrap);
}
?>

is one way…personally i save only the numbers and throw the rest away..makes it simpler and you can always change the display code to format a number for a particular use. 

$phone = preg_replace(”[^0-9]”,”",$_POST[’phone’]);

Posted by Suresh B

Leave a Reply

You must be logged in to post a comment.