Closed
Bug 1194812
Opened 9 years ago
Closed 6 years ago
Prevent users typing any character into <input type="number"> that would not be a valid part of a number (ignore those characters)
Categories
(Core :: Layout: Form Controls, defect)
Core
Layout: Form Controls
Tracking
()
RESOLVED
DUPLICATE
of bug 1398528
People
(Reporter: root, Unassigned)
References
Details
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0
Build ID: 20150702232110
Steps to reproduce:
Enter a string on number type field, then try to get it later
Actual results:
You obtain an empty result.
Fiddle: http://jsfiddle.net/qyd4geow/
Expected results:
You shouldn't be able to enter strings on a number type, as it is confusing for the inexperienced user, and causes troubles on javascript based validations.
Examples:
https://github.com/igorescobar/jQuery-Mask-Plugin/issues/201
https://github.com/guillaumepotier/Parsley.js/issues/751
Component: Untriaged → Layout: Form Controls
OS: Unspecified → All
Product: Firefox → Core
Hardware: Unspecified → All
Summary: HTML5's number type allows to enter strings, but not to get it → <input type="number"> allows to enter strings, but not to get it
Version: unspecified → Trunk
Comment 1•9 years ago
|
||
> You shouldn't be able to enter strings on a number type, as it is confusing for the
> inexperienced user
So is hitting a key and nothing happening, no? Add to that that the set of allowed keystrokes would be locale-dependent (e.g. '.' vs ','), and users would get quite confused.
(In reply to Boris Zbarsky [:bz] from comment #1)
> So is hitting a key and nothing happening, no? Add to that that the set of
> allowed keystrokes would be locale-dependent (e.g. '.' vs ','), and users
> would get quite confused.
Current standard does not use locale-dependent floating points (http://www.w3.org/TR/html-markup/input.number.html), so it's not a problem to consider.
On my consideration, to allow writing something that is not being processed as shown in screen is quite more confusing.
Comment 3•9 years ago
|
||
> Current standard does not use locale-dependent floating points
The standard doesn't define the processing of user input at all here. In practice, user input can use locale-dependent floting-point numbers.
Comment 4•9 years ago
|
||
(In reply to Boris Zbarsky [:bz] from comment #1)
> So is hitting a key and nothing happening, no? Add to that that the set of
> allowed keystrokes would be locale-dependent (e.g. '.' vs ','), and users
> would get quite confused.
And many different number characters of course: http://unicode.org/charts/
FWIW Chrome now ignores any attempt by a user to type or paste in characters that aren't one of the characters used in HTML's "valid floating point number" format or that aren't a valid digit or decimal separator in the user's system locale.
Summary: <input type="number"> allows to enter strings, but not to get it → Prevent users typing any character into <input type="number"> that would not be a valid part of a number (ignore those characters)
Updated•9 years ago
|
Component: DOM: Core & HTML → Layout: Form Controls
Comment 6•7 years ago
|
||
So, 3 years+ with such a bug...
Quote of the standard: "User agents must not allow the user to set the value to a non-empty string that is not a valid floating-point number."
And why is the ticket 1342477, with major priority closed without adjusting the priority here?
Updated•6 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 8•6 years ago
|
||
Technically this bug was filed first, but there's more useful discussion over in bug 1398528 at this point. So I'm duping this one to bug 1398528.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•