Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: Re: Another LostS Question - Phone Number Checks

by kjherron (Pilgrim)
on Aug 24, 2001 at 00:24 UTC ( [id://107503]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Another LostS Question - Phone Number Checks
in thread Another LostS Question - Phone Number Checks

It's not very user-friendly. You're forcing them to enter their phone number in a particular format, when you could just as easily format the number for them.

This is a pet peeve of mine. There's more than one way to punctuate phone numbers, and no standardization among web sites:

(xxx) yyy-zzzz +1 xxx yyy zzzz xxx-yyy-zzzz xxxyyyzzzz
Even if your instructions are perfectly clear about the expected format, the individual using it may be used to entering it in some other form. Handling multiple formats is much more user-friendly than issuing an error message.

A simple way to handle this is to accept any old cruft they type, remove everything that isn't a digit, and make sure you got ten digits. You can then format those digits for display or whatever:

$conphone =~ tr/0-9//dc; # remove non-digits if ($conphone =~ /^(\d{3})(\d{3})(\d{4})$/) { $conphone = $1 . '-' . $2 . '-' . $3; } else { print "Bad phone! No cookie!\n"; }

Replies are listed 'Best First'.
Re: Re: Re: Re: Another LostS Question - Phone Number Checks
by Brovnik (Hermit) on Aug 28, 2001 at 15:22 UTC
    <soapbox> I agree about the "pet peeve". Often, I try to register on a US site and it won't accept my UK phone number.
    Even UK systems screw up since we often have number changes and the websites often don't change quickly enough.
    Suggestion (adding to comments by [id://kjherron]) :

    Allow any format, strip down to digits, and check for a reasonable number of digits to allow for international dialing codes, etc. then leave it at that.

    If you want real validation, you'll need to check the dialing codes for each potential country to see if they are OK, and KEEP THE DATABASE UP-TO-DATE.
    </soapbox>
    --
    Brovnik

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://107503]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-20 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found