New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setSelectionRange for number input #3032
Comments
If you want this to be considered you'll need to address the points made in https://www.w3.org/Bugs/Public/show_bug.cgi?id=24796#c49 (it might also not hurt reading that bug through to get a sense of the problem space). |
Also, you're explicitly not supposed to use type=number for telephone numbers... Given that misconception, I think it's best we close this, since we don't have any use case presented. Happy to continue discussing in the closed thread though, and reopen if a use case is presented that shows evidence of addressing the linked bug's concerns. |
I think it makes sense to re-open this - setting aside telephone numbers, there are many types of sectioned number inputs where it can make sense to examine selection.. for example social security number, credit card number, serial numbers, etc.. Its a common use case to implement these as multiple inputs for visual effect, and then to control selection w/ javascript so that as a user types it moves between the inputs naturally. Its important to use a number input so that mobile browsers use the appropriate keyboard, but the lack of control over selection range prevents doing things like moving selection to the input for the previous group of numbers when the left arrow or delete key is pressed with the cursor at the beginning of an input. |
All of those are not appropriate for input type=number. Please read the spec for input type=number!! |
There is no practical alternative to input type number in iOS safari and android chrome that will bring up the appropriate keyboard. Specifying which keyboard should be used by mobile browsers is by far the most important practical use of input types. I see in the spec the note that 'The type=number state is not appropriate for input that happens to only consist of numbers but isn’t strictly speaking a number.', but number inputs are widely used for credit card numbers (by stripe, amazon, etc..) because of the lack of alternatives. |
OK, so it sounds like you should file a bug with Safari and Chrome then! (But, I am pretty sure the pattern="" attribute does what you want; see e.g. https://stackoverflow.com/a/6512618/3191 and various other Google results. If it doesn't, then file the bugs!) |
Wow - I did not know that worked! that does satisfy my use case, thank you. |
|
@annevk unfortunately no and I agree that would be the proper way. |
In order to provide a cross platform solution to auto-format telephone numbers while providing the best user experience on mobile devices one would need to be able to manipulate the selection range for number inputs. Since this is currently not possible we must provide users with a sub-par experience.
The text was updated successfully, but these errors were encountered: