Hello,
Here is the correct validation code for a telephone number with 8 numbers:
function phone($phone)
{
if($phone=='' || !numeric($phone) || (strlen($phone)!=8)) return false;
if(eregi('^\([0-9]{3}\) [0-9]{3}-[0-9]{4}$', $phone ))
return false;
else
return true;
}
It doesn't matter what the name of the field is. Note this is a validation rule so the name of the function will appear in the "Validation Rule" drop down.
Also if anyone else will want to use this function, but with other telephone number length (or without number length limit) please change this line:
if($phone=='' || !numeric($phone) || (strlen($phone)!=8)) return false;
To:
if($phone=='' || !numeric($phone)) return false;
Or just change the limit from 8 to what number would you want.
Regards!