Vladimir
Vladimir

Reputation: 13173

How do I automatically switch focus of input elements on on HTML form?

I have an HTML form with three inputs for phone number input. I want a cursor to move to the next input after the current one is filled.

Like you entered three digits in the first box, and then the cursor moves to the second, and after it is filled, moves to the third.

Is it possible to accomplish this without JavaScript?

Upvotes: 1

Views: 5006

Answers (1)

JKirchartz
JKirchartz

Reputation: 18042

I don't condone auto-tabbing, I think it irritates & confuses some users, but here's one way to do it in "Obtrusive JavaScript": http://www.javascriptkit.com/script/script2/autotab.shtml

I'm not a big fan of having 3 inputs for 1 phone number, because then you have to write extra code to combine them. It just seems illogical, inputs & data should have a 1:1 ratio.

Upvotes: 1

Related Questions