Open Bug 1392068 Opened 8 years ago Updated 3 years ago

Input type=number fails to parse '+' (plus) sign

Categories

(Core :: Layout: Form Controls, defect, P3)

54 Branch
defect

Tracking

()

UNCONFIRMED
Tracking Status
firefox57 --- wontfix
firefox58 --- wontfix
firefox59 --- ?

People

(Reporter: mozilla, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36 Steps to reproduce: Enter "+2.00" in an `<input type="number">` form field, and find that Firefox the value of that input is an empty string. See also: https://stackoverflow.com/a/45774706/419956 Reproduced with this code on Firefox 54.0 (64-bit) on Windows 10 (64-bit) Pro: ```html <input id="nr" step="0.01" type="number"> <button id="btn">ConsoleLogIt!</button> ``` and ```javascript document.addEventListener("DOMContentLoaded", function(event) { document.getElementById("btn").addEventListener("click", function(evt) { var nr = document.getElementById("nr").value; console.log({ nr: nr, type: typeof nr, directAdd: nr + 1.00, parseThenAdd: parseInt(nr, 10) + 1.00 }); }); }); ``` Actual results: Actual output: ```javascript { "nr": "", "type": "string", "directAdd": "1", "parseThenAdd": NaN } ``` Expected results: Expected output: ```javascript { "nr": "2.00", // or "+2.00" "type": "string", "directAdd": "2.001", // or "+2.001" "parseThenAdd": 3 } ```
I posted the bug from Chrome, not realizing my UA would be incorporated in the post. The UA from my description is Chrome's UA, this is what my Firefox console tells me for `navigator.userAgent`: > Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0
Component: Untriaged → Layout: Form Controls
Product: Firefox → Core
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.