Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
I Wanted to Type a Number (2016) (filamentgroup.com)
97 points by bpierre on March 26, 2019 | hide | past | favorite | 40 comments


This advice is incorrect to recommend using type="number". On a desktop, trackpad and mousewheel scrolling while the pointer is hovering over and/or focus is within a type="number" field will alter the number within it, resulting in undetected data errors as digits off-by-one without user awareness.


Not sure if its just me, but I tried it and the mouse wheel does not cause the numbers to change, either focused or not. (latest chrome on mac)


Firefox on Windows does this when control is in focus and the mouse cursor is over the control.


Also, things might get a bit weird when you enter this 16-digit... uhh... "invoice number": 9007199254740992.


your comment is spot on, here is a recent relevant article in HN about it: https://news.ycombinator.com/item?id=19479464


The article mentions this problem near the end, and the component they built provides a solution.


Not seeing this behaviour in Safari or Chrome Mac - whwere are you seeing it?



Since many websites already implement their own input fields, I see one solution: implement the entire keyboard in JavaScript

/s


The default keyboards are inflexible for so many reasonable use cases that I would actually consider this unironically.


What use case is there for (able-bodied) people where a websites own implementation of an on-screen keyboard would improve anything?


I think this may have been the result of banking malware (e.g. Zeus back in the day) which was hooking OS calls to capture keyboard input and steal passwords. I'm not sure whether the on-screen keyboards would be vulnerable in other ways though.


I have had to use a online banking site (from a very, very big global corporate bank) which implemented a keyboard in the (Desktop) browser which you had to click each letter with a mouse to type out your password (in the name of security, presumably).


BNP Paribas? It's what I have to use to enter my password (which is only 6 char long, no choice there)


Indeed BNP Paris does that for the Pin number, so it's only numbers you have to type.

It has been there or a long time, so I kinda consider it a remnant of the old battle against keylogger, since the number position changes. It does seem outdated now, and I'm unsure if it's still useful compared to all the other possible checks they could implement.


It's not my PIN number, it's used as a password to access on-line banking services. But I agree that it look like it's design to defend against keylogger; I don't know how efficient it is.


The worst is a "PIN" input that is only numbers, and the numbers on the keyboard are behind a modifier key, that you have to hit for every, single, number. Not including negative, separator and decimal characters on number input is worse.


Well, on most "virtual" mobile phone keyboards you can long-press the modifier key in the same way as CAPS LOCK and friends worked on our old mechanical keyboards.

Nevertheless, virtual keyboards need to be improved, and in my opinion it's not the websites faults. It's the browser who has to do its job.


On LG phones they add the numbers to the top of the querty keys. On Android you can install alternative keyboards.


Hacker's Keyboard is a good choice for Android phones.


I've used it, it's not a very good experience for conversation... I mostly use gboard, because of gesture input. I'm in several conversations and/or emails a day, I only have to input a numeric pin like described maybe once a month. Doesn't mean it shouldn't be improved on.


Same for iOS, fyi.


Ah true, I forget on my iPad I installed an alternative keyboard. I said Android cause I have more experience using Android. I sort of stopped using my iPad once I bought a Surface Book 2. Since it has a Netflix / Hulu app I dont need my iPad as much anymore.


How about a new attribute to match what phones actually provide: keyboard=text|digits|url|emoji


I have been thinking about a similar question while building a image hosting site.

Which resolution of thumbnail should I provide for each client?

On a desktop, I can be reasonably sure that the user doesn't have limited data or bandwidth, but their resolution (and dpi) might be quite small.

On mobile, the user might have a hiDPI screen which indicates I should send them a high-resolution thumbnail. But I don't know if they would like me spending their limited data or bandwidth that liberally.

So far, I haven't found a way to indicate or request these sort of preferences, but with the up-and-coming support for srcSet, <picture> elements etc., I would love to provide multiple thumbnail alternatives if a client could reasonably decide between them.


A possible solution, but it requires JavaScript enabled, and manual work, is to have a service worker provide such information up to the server.


Honestly something we'd all love to see


That's a very detailed study.

As a user, I whish there was an easy way to just change the keyboard to what I want to input. Android/Google keyboard seems to have something like that nowadays (deeply hidden, however), i.e. the possibility to switch to a numeric keyboard, as a user.


Have you tried AnySoftKeyboard on android? It's open source and fully customizable with different layouts and allows you to switch between different entry methods with a swipe or button press.

I've got a QWERTY layout, both regular and one with extra keys for terminals, a full number layout and a keypad layout all easily switchable. It also has what's surprisingly become one of my favourite features, left and right arrows at the top. It helps so much with text navigation, especially when writing long blocks of text.


I was going to recommend that. It's a very nice program, and also happens to be open source.


We were dealing with this today! so we want to use type="number" but it doesn't work!

first, the browser default error message is not accessible.

then we decided to use novalidate="novalidate" to tell browser to not do the validation.

Chrome does not submit the value if the input is not perfect numeric ( try "......"). so it does wipe out user input without letting us catch it on the server!

We just changed it back to type="text" !:(


ZIP code should be a number pad for every American, but if someone ships or bills to Canada then you have to have the letters. Not much you can do about that, unfortunately.


Nope. ZIP codes have to support leading zeros which won't happen with a numeric entry. There could also be a hyphenated +4 suffix for pedants. Post codes must always be treated as text.


From a user input point of view, a numeric keypad or slightly modified numeric keypad would easily suffice.

Or, display a numeric keypad as default with a text keypad available.

There are better solutions than what is currently offered.


The falsehood that it is correct to treat ZIP codes as one would treat numbers is on the list.

* https://mjt.me.uk/posts/falsehoods-programmers-believe-about... (https://news.ycombinator.com/item?id=5791489)


    if (country === countries.US) {
        input.setAttribute('inputmode', 'numeric');
    }


That doesn't work.

For example, The Hartford Fire Insurance company's address is

    HARTFORD FIRE INS CO
    1 HARTFORD PLZ
    HARTFORD CT 06115-1703
Note the zip. Leading zero, and the last 4 digits. There are other businesses at the same address, with different zip codes. EG

    HARTFORD FINANCIAL SERVICES
    1 HARTFORD PLZ
    HARTFORD CT 06115-1709
Etc, etc. Zip codes in the US are text strings, that happen to be composed of the digits 0-9 and a hyphen.


And what do you do with the following zip codes?

https://en.wikipedia.org/wiki/List_of_ZIP_Code_prefixes#Star...


Gee, it would have been better if all this was is a suggestion for which keyboard layout to show initially


Please add (2016) to the title.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: