Skip to content

feat(forms): support binding number|null to <input type="text">#67268

Open
alxhub wants to merge 1 commit intoangular:mainfrom
alxhub:sf/number-in-text
Open

feat(forms): support binding number|null to <input type="text">#67268
alxhub wants to merge 1 commit intoangular:mainfrom
alxhub:sf/number-in-text

Conversation

@alxhub
Copy link
Member

@alxhub alxhub commented Feb 25, 2026

<input type="number"> often does not provide the desired user experience when editing numbers in a form. MDN even describes how text inputs should be used in many cases instead, via <input type="text" inputmode="numeric"> or similar configurations. Previously, this did not work with Signal Forms without a custom input component/directive.

This PR builds support for binding number|null models directly to <input type="text"> native controls via [formField]. When a model has a number or null value, signal forms will preserve that status when the user makes edits/changes. Empty string values are converted to null, other values are parsed as numbers, and a parse error is raised when a non-numeric value is entered.

Note that it's up to the UI developer to configure additional UI affordances such as setting an appropriate inputmode, rejecting non-numeric keypresses, etc.

Fixes #66903
Fixes #66157

`<input type="number">` often does not provide the desired user experience when editing numbers in
a form. MDN even [describes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/number#using_number_inputs)
how text inputs should be used in many cases instead, via `<input type="text" inputmode="numeric">`
or similar configurations. Previously, this did not work with Signal Forms without a custom input
component/directive.

This PR builds support for binding `number|null` models directly to `<input type="text">` native
controls via `[formField]`. When a model has a number or `null` value, signal forms will preserve
that status when the user makes edits/changes. Empty string values are converted to `null`, other
values are parsed as numbers, and a parse error is raised when a non-numeric value is entered.

Note that it's up to the UI developer to configure additional UI affordances such as setting an
appropriate `inputmode`, rejecting non-numeric keypresses, etc.

Fixes angular#66903
Fixes angular#66157
@alxhub alxhub requested a review from crisbeto February 25, 2026 02:24
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: forms labels Feb 25, 2026
@ngbot ngbot bot added this to the Backlog milestone Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: forms detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Signal Forms allow diferent numeric input methods Signal forms, number input with inputMode="decimal" fails with localized decimal separator

1 participant