...

View Full Version : Autoformat Phone Number



OpenIntro
11-12-2004, 10:59 PM
Quick question regarding an AutoFormat Phone Number script that I found here:

http://www.multi.com/Coding/FormatPhone.html

There seems to be a small bug….when you type in the first 4 numbers, and it shows (xxx)x and then you delete two characters back to (xx…..the next character typed causes it to do (xx)x


Any idea how to fix this? Would be much appreciated!

BrightNail
11-13-2004, 12:54 AM
hmmm,
works fine for me..

it won't let me delete any numbers pass this point.

x(xxx

so it always works. I am on a linux box.

OpenIntro
11-13-2004, 01:28 AM
hmmm....

when you type in a full phone number (all 10 digits) and then delete all the way back to the opening ( but not deleting it. And then typing 10 more numbers, it formats correctly?

Brandoe85
11-13-2004, 01:37 AM
It seems to be an IE thing, works fine in firefox.

jalarie
11-15-2004, 02:53 PM
I like to let a user enter the telephone number in any format s/he likes, and then I reformat it to what I want using a JavaScript function.

For a demonstration, go to the "Samples of my work > Order form" page at "http://spruce.flint.umich.edu/~jalarie/" and fill in the "Telephone" box. When you tab out of it, the number will be reformatted to put parenthesis around the area code, a dash after the first three digits, and the extension number after an "x". You may use upper-case letters like "1-800-2RAMADA" or "800-HOLIDAY" if you like.

The code is too long to post; if you'd like a copy, please e-mail me directly at "jalarie@umich.edu" and request a copy of "phonfmt1.js" file.

OpenIntro
11-15-2004, 06:32 PM
I like how your script reformats after the user tabs out of the field. Question about the script, say a user types in the 10 digits and then clicks on a submit button....does the script still format the text box when the submit is sent?

OpenIntro
11-15-2004, 06:40 PM
It seems to be an IE thing, works fine in firefox.

I just tried the script in Firefox....and there seems to be a different prob in Firefox....type in all 10 numbers....and then start deleting back, and I am not able to delete past the )....can't delete the (xxx without highlighting and deleting.....

jalarie
11-15-2004, 06:50 PM
I like how your script reformats after the user tabs out of the field. Question about the script, say a user types in the 10 digits and then clicks on a submit button....does the script still format the text box when the submit is sent?

Yes, it does.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum