...

View Full Version : Changing focus when text length reaches limit



markhartnady
03-10-2004, 05:25 PM
I need to change the focus of a text box when its text length reaches 2.

I.e.:

Three text boxes:

1: [ ] 2: [ ] 3: [ ]

Now when the user types in box 1 and the text length reaches 2 it should set focus to the second.

I tried this:

<input name="text1" onChange="javascript:
if (document.form.text1.length == 2) document.form.text2.focus();
">

But it didnt work.

Willy Duitt
03-10-2004, 05:34 PM
Try this:

<input name="text1" onkeyup="javascript&#58;
if (this.value.length == 2) document.form.text2.focus();">

.....Willy

Edit: Added 'purty colors :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum