on 8/2/01 9:55 PM, Richard Lynch at [EMAIL PROTECTED] wrote:

> While the solution given will work, consider the following perfectly valid
> phone numbers:
> 
> 312-555-1234x1001
> 1-800-MY-STUFF
> 
> Also, once you strip out all the spaces and dashes, nobody but a computer
> can use it...
> 
> Do you *really* want to make it difficult for humans to use?

good point richard. i never really considered the 1-800-MY-STUFF case. most
of my customers seem to want numbers only..

anyway, assuming numbers only and no extensions (you can change this to add
extensions pretty easily)...

in a form where i want a phone number, i have 3 separate fields of length
3,3,4 respectively. when the form is submitted, i check to make sure there
are only numbers. (actually, on some sites i use javascript to check this as
well)

i have two functions--phone_from_3() and phone_to_3(). i use phone_from_3()
to set $phone = $phone1 . $phone2 . $phone3. i then put $phone in the db.
when i want to display the phone number somewhere, i use phone_to_3() to
turn $phone into $phone1, $phone2, $phone3. i can then format the phone
number making it easy to read.

hope this helps,
mike

 -- mike cullerton



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to