www.webdeveloper.com
Results 1 to 5 of 5

Thread: curser moving automatically between fields on a form

  1. #1
    Join Date
    Nov 2002
    Location
    Canada
    Posts
    11

    Question curser moving automatically between fields on a form

    I am creating a form and would like the cursor to automatically jump to the next field - especially when entering a phone number that I've set up as a 3+3+4 type of thing. How would I accomplish this?

    Thanks in advance!

  2. #2
    Join Date
    Nov 2002
    Posts
    984
    You could use the maxlength attribute on <input> from where your JavaScript could get the size.
    http://www.w3.org/TR/html4/interact/...adef-maxlength

    eg
    <input size="3" maxlength="3">
    <input size="3" maxlength="3">
    <input size="4" maxlength="4">

    It also prevents people from entering too many numbers in 1 field even if JS is not available (but they have to press tab manually to jump to the next input box of cource =)
    // Stefan Huszics

  3. #3
    Join Date
    Nov 2002
    Posts
    984
    Originally posted by Dave Clark
    Note to laria: If you care about those who use NS4, you will have to do as I suggested above. In other words, the maxlength attribute, mentioned, does not work in that browser/version (maybe others, too).

    Dave
    Just out of interest, wouldn't a javascript be able to get the value of maxlenght even if the browser doesn't implement the correct behaviour in the HTML?
    // Stefan Huszics

  4. #4
    Join Date
    Nov 2002
    Posts
    984
    Originally posted by Dave Clark
    NS4 will only allow new properties that are created from within JavaScript itself.


    It's stuff like that makes you glad NS 4 is on the way to die out
    // Stefan Huszics

  5. #5
    Join Date
    Nov 2002
    Location
    Canada
    Posts
    11
    well yeah.. I wasn't thinking that I had to worry about dated versions of browsers. I thought about it afterwards too and most people are used to tabbing between fields and to throw something different at the general population is usually devastating to them anyway People like 'same ole same ole'.
    Thank you all for taking the time to respond. I appreciate it

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles