Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing focus when text length reaches limit

    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.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:
    Code:
    <input name="text1" onkeyup="javascript&#58; 
    if (this.value.length == 2) document.form.text2.focus();">
    .....Willy

    Edit: Added 'purty colors


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •