Closed Bug 1722829 Opened 3 years ago Closed 3 years ago

change event not firing when text entered in input[@type=number]

Categories

(Core :: DOM: Core & HTML, defect)

Firefox 90
defect

Tracking

()

RESOLVED DUPLICATE of bug 1398528

People

(Reporter: 1981km, Unassigned)

Details

Attachments

(1 file)

282 bytes, application/xhtml+xml
Details
Attached file test.xhtml

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0

Steps to reproduce:

  1. Open the attached document.
  2. Open Web Developer Tools' console.
  3. Enter something that's not a number in the input field.
  4. Commit the entered value (e.g. by clicking outside the control).

Actual results:

No output happens to the console.

This is pretty bad, indicating that the change event isn't firing. I want to alert the user if he enters a value which is not a natural number (I didn't include the full code, but it has attribute min="0" and call to checkValidity in the handler). This bug allows the check to be circumvented by first clearing the field, committing the empty value (this does cause handler call) and then focusing the field again and entering some text.

I've come up with adding required="" as a workaround. But it shouldn't be necessary. What if I do want the empty value to be valid (and e.g. mean 0 – just a matter of handling NaN in the script)? I could drop type="number" and deal with that manually, but it's cumbersome and semantically poorer.

Expected results:

The message "function validate called" should be displayed in the console.

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

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core

Chrome behaves same, except that Chrome does not insert non-numeric characters from key press. So I think this really is bug 1398528.

Please reopen if you disagree.

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

Created:
Updated:
Size: