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!
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...
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. . .
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)