Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moving from one textfield to another

Status
Not open for further replies.

overDeveloper

Programmer
Dec 11, 2006
58
US
I want to have focus shifted from the one that has focus to another once a certain amount of characters has been entered. I have tried:

Code:
<input .... onkeyup="if (document.GetElementById['field1'].length == 3) {document.GetElementById['field2'].focus();}"

But I get an error saying that document.GetElementById.field1 is null or not an object.. any help?
 
The G should be g and the [] should be ().
Also make certain you have a corresponding id tag in the input fields.
Code:
<input .... onkeyup="if (document.[COLOR=red]g[/color]etElementById[COLOR=red]([/color]'field1'[COLOR=red])[/color].length == 3) {document.[COLOR=red]g[/color]etElementById[COLOR=red]([/color]'field2'[COLOR=red])[/color].focus();}"

At my age I still learn something new every day, but I forget two others.
 
Oh, and document.getElementById('field1').length
should be: document.getElementById('field1').value.length

At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top