User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050725 Firefox/1.0+ Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050725 Firefox/1.0+ Flickering due to parseInt changing the textbox value if a non-digit key is pressed. Very minor, bikeshed problem, but nonetheless I'd like to see this fixed sometime in the future. Reproducible: Always
OS: Windows XP → All
Hardware: PC → All
Version: unspecified → Trunk
13 years ago
Assignee: nobody → tonglebeak
Status: UNCONFIRMED → NEW
Ever confirmed: true
Created attachment 190635 [details] [diff] [review] filter out non-digit keypresses This prevents non-digit keys from being pressed. The exceptions are delete, backspace, and the arrow keys. I'm not going to request any review on this at this time since it's too trivial, and 1.9 branching is very close, but it's here for people to test and provide input upon.
Comment on attachment 190635 [details] [diff] [review] filter out non-digit keypresses mconnor, I'm fully aware of your concerns about pasting text into the box, here it goes: IE will accept non-digit pasting, and when ok'ed the history is set to 99 days. Rather than doing something stupid like that, I figured we should leave the parseInt in as a fail-safe, and since very few people actually paste numbers into the boxes, pasting shouldn't be causing any worries. Bottom line is that this flat-out stops non-digit key input (but does allow delete, backspace, and arrow keys), and thus resolves the flickering. And for anyone who actually cares to try to screw with it, parseInt is still there as a failsafe.
Why not use something like checkInteger()? The only possible values can be integers, so why not just check to see if the values an integer, instead of checking if it's not an integer? http://lxr.mozilla.org/mozilla/source/toolkit/components/printing/content/printdialog.js#94 http://lxr.mozilla.org/mozilla/source/toolkit/components/printing/content/printdialog.xul#99
The regex in my function DOES check for an integer, and will return false if it's not an integer (or any of the special keys). Here's how it works: you got your testInput() and specialKeys(). if (!testInput && !specialKeys), then no valid key was pressed, so it's returned true, but then it's NOT because of the ! outside all of that. Only one of the conditions have to be met to succeed (as it's only doing with one keypress, make sense?). Plus, onkeyup, someone can hold down the key, can they not, and have letters go up the wazoo, then let go and watch it all reset to nothing. This just stops that period.
Comment on attachment 190635 [details] [diff] [review] filter out non-digit keypresses Cancelling for now until a possible better fix is discussed with mconnor.
This is now a WFM Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9) Gecko/2008062219 (Gentoo) Firefox/3.0 Anyone else still having this problem?
Status: ASSIGNED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.