File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes phone number input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "phone number input " Watch "phone number input " New topic
Author

phone number input

steve Pentas
Greenhorn

Joined: Mar 05, 2009
Posts: 14
I want to create a html (actually JSP, but I assume this is a html issue..) which has a field that lets user enter 10 digits phone number. However, I want to separate the field into 3 box. First box contains 3 digits, user can click tab after finishing the first box, it should automatically jump to the 2nd box which contains 3 digits, and the 3rd box contains 4 digits. I am sure we have all seen such forms. I need to take the hone number input as a whole string from my "<form>". How do people usually handle such trick ?

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60764
    
  65

I rather dislike the three-box method and prefer a single box in which I let the user enter a free-form string of digits with whatever punctation they please. On input I simply strip out anything that's not a digit and verify that there are the 10 digits left.

To make the 3-box format "auto-tab" simply check the length of the input in a key event handler, and focus to the next input if it's "full".


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
There are plenty of examples out on the net. A google search should turn up decent results. [I also hate the 3 box input]

Eric
steve Pentas
Greenhorn

Joined: Mar 05, 2009
Posts: 14
A follow-up question --- Do you mean if I use 3 box format I have to use javascript then (assume I want the "tab" over feature) ?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Google: JavaScript Autotab Phone

It should give you what you need.

Eric
 
wood burning stoves
 
subject: phone number input
 
Similar Threads
Input Text in Data Tables and Validation Errors
AWT Combo Box
Struggeling with regexp
how to generate a unique number from a series of numbers
Question about JDialog?