On Apr 16, 1:02 am, "Rick Wright" <rbw95... DeleteThis @gmail.com> wrote:
> GlacierHi -
>
> I need to validate a field in my database where the user will input their
> phone number. I would like to ensure that the area code is included. The
> field is setup as follows:
>
> hphone varchar(12)
>
> What is the best way to check to see if this format 123-456-7890 is entered?
> Thank you in advance for any assistance.
>
> - Rick
Here ya go. I had to look for one a while back.
<?php
function checkPhone($number){
if(ereg("^[0-9]{3}-[0-9]{3}-[0-9]{4}", $number)) {
return true;
} else {
return false;
}
}
?>
>> Stay informed about: Validating a field for correct input