Results 1 to 3 of 3

Thread: onkeyup tabkey

  1. #1
    Join Date
    Jul 2012

    onkeyup tabkey

    Hi - fairly new, so hope this isn't a silly question. I'm using a clientside javascript function to validate user input. The function is triggered by an onkeyup which passes the input data in a table (input type = "text").

    The function includes

    validChars = /[1-9]/
    if(inputNumber.value.match(validChars)) to determine a response.

    This works fine except that the tab key which moves from cell to cell in the input table also triggers an invalid input. I've tried including \t to allow tab through but this doesn't work.

    Second question (if I may) how do I allow arrow keys in HTML for user movement from cell to cell, as well as tab key?

    Your help for a newbie much appreciated!

  2. #2
    Join Date
    Oct 2010
    Versailles, France
    Your regular expression is made to test only one character ! She can thus work only by testing the last character read with a charCode or keyCode... If you test the full entry with a value, you have to test many characters with something like this /^[\t1-9]+$/ or this to allows zeros after the first character /^[\t1-9][0-9]+$/. A variant could consists to make the test with a onblur event...

    For the second question your have all to do by catching an event (keypress, keydown or keyup) an play with the focus. But there is probably solutions on the web...

  3. #3
    Join Date
    Jul 2012


    The input field is only one character, which is why i did it that way, But I can see what you mean, its testing the tab key rather than the entry. Not quite sure I follow the solution, though. . .

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