Closed Bug 1756160 Opened 3 years ago Closed 3 years ago

Bug in input value when type number and spaces used with getElementById

Categories

(Core :: Layout: Form Controls, defect)

Firefox 97
defect

Tracking

()

RESOLVED DUPLICATE of bug 1398528

People

(Reporter: depicus+bugzilla, Unassigned)

Details

Attachments

(1 file)

2.32 MB, application/zip
Details
Attached file Archive.zip

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15

Steps to reproduce:

Create an input

<input type="number" data-cardinal-field="AccountNumber" id="AccountNumber" name="AccountNumber" value="4000000000000002" autocomplete="cc-number" />

then on button press read the value

let text = document.getElementById('AccountNumber').value
console.log("card number is " + text);

Actual results:

if you use no spaces the value is used and is correct but if you type or paste in a value with spaces no value is sent so i.e. 4000 0000 0000 0002 would be blank

Expected results:

Ideally the spaces are removed or sent for the dev to remove.

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Form Controls' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Layout: Form Controls
Product: Firefox → Core

Thanks for the bug report!

This is essentially a version of bug 1398528, which is unfortunately non-trivial to fix in general (see bug 1398528 comment 3 and 4; the spec doesn't dictate exact behavior here, and Safari continues to match our behavior, and fully-correct blocking is non-trivial due to localization complexity).

In the meantime, see bug 1398528 comment 26 for a sort-of workaround; you can use JavaScript or CSS to detect the fact that the number field contains an invalid number (and alert the user to that fact so that they can edit or reenter it).

--> Marking as duplicate of bug 1398528

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: