Dealing with Phone Numbers in web application

chockomonkey

[H]F Junkie
Joined
Oct 11, 2003
Messages
8,328
Here's another situation that I went into thinking it'd be easy, but then came across roadblock after roadblock along my way.

Most web forms nowadays have nifty input fields for phone numbers where you type in the numbers and it automatically fills in the parenthesis around the area code, a + before the country code if entered, and a dash between the latter 3 and 4 digit numbers. Then i imagine it just passes the numbers along to be stored in your database, cause why would want that extra fluff in your db? (or does it matter?)

I'm working with python + flask: can anyone recommend a python library to work with phone numbers and/or perhaps a javascript library to implements this spiffy functionality?

Or perhaps just fill me in on how you handled this in your own web app.

Thanks!
 
mmm i just happened upon javascript masking. Methinks this is what i've been looking for.
 
I wrote my own lib for dealing with such in php.
I stored the number in the database without any dashes,spaces or parentheses but displayed with.

I had to write my own because my webapp didn't use U.S numbers so nothing existed out there before to to this.
 
I wrote my own lib for dealing with such in php.
I stored the number in the database without any dashes,spaces or parentheses but displayed with.

I had to write my own because my webapp didn't use U.S numbers so nothing existed out there before to to this.

Thanks for sharing your experience with this. Thankfully I just have to deal with the US and Canada. But ultimately I decided to just forget about this whole idea. I'll just be using a simple text box for this, as there is often other information which needs to be included along with the phone number.

The lazy way out? perhaps lol
 
Input validation is often the most annoying aspects of building a robust web app, so I feel your pain.

Thankfully, unless your application actually has to do something with the phone number — like programmatically dial it or send automated SMS alerts to it — you don't really need to validate it. I've only ever dealt with U.S. numbers for 2FA, so I simply accept ten digits and confirm the validity via an SMS challenge.
 
Back
Top