Calculator number input
Calculator Locale Number Input Test Matrix
A strict locale-aware parsing contract and sixteen executed cases for decimal marks, grouping, scale, ranges and recoverable calculator errors.
Direct answer
Do not parse calculator numbers by deleting commas and periods. Choose one accepted locale, derive its decimal and grouping tokens, validate the complete string and grouping pattern, enforce sign, scale and range rules, then normalize exactly once. Preserve the user's original entry for an accessible correction path; treat ambiguous and mixed conventions as errors rather than guesses.
Definition
Locale-aware numeric input is the process of accepting, validating and normalizing a number under one declared locale and numeric policy. Formatting and parsing are different operations: a formatter can expose a locale's tokens, but an application still needs an explicit parser, scale, range and error-recovery contract.
Key findings
Verified 21 October 2026
- The same visible punctuation can represent different values: 1,234.56 is valid under the published en-US contract, while 1.234,56 is valid under de-DE and rejected under en-US.
- Intl.NumberFormat and formatToParts identify locale-specific output tokens, but they do not replace an application's parsing and validation policy.
- Grouping must be validated before punctuation is removed; otherwise 12,34.56 can be silently transformed into an unintended number.
- The reference parser preserves the original string for recovery and stores a separate normalized machine value only after the complete string, scale and range pass.
What must a locale-aware number contract define?
A locale name alone is not enough. Publish the field's number type and every decision that can change acceptance or the stored value. Version the contract with the formula so later CRM records, calculations and corrections can be replayed.
LOCALE-NUMBER-INPUT-MATRIX
| Rule | Published reference | Why it matters |
|---|---|---|
| Locale | en-US, de-DE or fr-FR per field | Selects decimal and grouping tokens |
| Digits | ASCII 0–9 | Non-Latin digits need a separate documented path |
| Grouping | Optional; exact groups of three | Prevents punctuation deletion from hiding bad grouping |
| Sign | Minus allowed; plus and parentheses rejected | Avoids undocumented accounting or sign conventions |
| Exponent | Rejected | Keeps ordinary calculator fields distinct from scientific input |
| Scale | At most two fractional digits | Separates validation from an explicit rounding policy |
| Range | Field-specific minimum and maximum | Stops valid syntax from becoming an invalid business value |
| Recovery | Preserve original string | Lets the user correct exactly what they entered |
Why are formatting and parsing different?
Intl.NumberFormat formats a numeric value for a locale, and formatToParts exposes output components such as integer, group, decimal and fraction. Those parts are useful for deriving tokens and constructing examples. They do not define which arbitrary input strings an application should accept.
The HTML number control stores a valid floating-point representation even when a browser localizes its interface. The standard also notes that a text control with inputmode can be more appropriate when the spinbox interface is not suitable. Whichever control is used, the server still needs the same input contract as the client.
What did the sixteen locale-input tests cover?
All sixteen cases ran against the published strict reference parser on 21 October 2026. A rejection is an intentional state with a specific correction path, not a failed attempt to guess the user's meaning.
| ID | Locale and entry | Expected decision |
|---|---|---|
| N01 | en-US · 1,234.56 | Accept 1234.56 |
| N02 | de-DE · 1.234,56 | Accept 1234.56 |
| N03 | fr-FR · 1 234,56 | Accept 1234.56 |
| N04 | en-US · 1.234,56 | Reject mixed convention |
| N05 | de-DE · 1,234.56 | Reject mixed convention |
| N06 | en-US · 12,34.56 | Reject bad grouping |
| N07 | de-DE · 12.34,56 | Reject bad grouping |
| N08 | en-US · 1234 | Accept 1234 |
| N09 | en-US · +1234 | Reject disallowed plus |
| N10 | en-US · (1,234.56) | Reject unsupported parentheses |
| N11 | Empty required field | Required error |
| N12 | NaN or Infinity text | Reject non-finite text |
| N13 | en-US · 1e3 | Reject disabled exponent |
| N14 | en-US · 1.234 | Reject scale over two |
| N15 | −1 with minimum 0 | Range error |
| N16 | 1001 with maximum 1000 | Range error |
Worked example: de-DE 1.234,56
Under the published de-DE contract, period is the grouping token and comma is the decimal token. First validate that 1.234,56 has a one-to-three digit leading group, one three-digit group and no more than two fractional digits. Then remove the permitted period, replace the permitted comma with a period and convert the normalized string 1234.56 to a finite numeric value.
Under en-US, the same original string is invalid. The reference does not silently convert it to 1.23456 or 123456. The original string remains available in the field, while the normalized value is stored only after validation succeeds.
How should calculator errors recover accessibly?
Put the expected format in a visible label or nearby instruction, using an example appropriate to the selected locale. When validation fails, identify the field and the accepted format in text, associate the message programmatically with the field and preserve the original value. Do not rely on placeholder text or color alone.
W3C notes that client-side validation can be bypassed and server-side validation is still necessary. Apply the same locale, scale and range contract on both sides; a browser-valid control is not evidence that the downstream calculator, CRM or email received the intended number.
Locale-number release checklist
Ship the field only when display, client parsing, server parsing, calculation and downstream storage agree.
- Declare one accepted locale or make locale selection explicit.
- Derive and test the exact Unicode decimal and grouping tokens.
- Validate grouping before removing separators.
- Define sign, exponent, whitespace, scale and range rules.
- Keep formatting separate from parsing and calculation precision.
- Preserve the original entry through every recoverable error.
- Use visible format instructions and programmatic error associations.
- Repeat validation on the server before calculation or delivery.
Verification and correction path
The three primary guidance sources and all sixteen deterministic fixtures were checked on 21 October 2026. A correction report should include the locale, exact Unicode code points, original entry, intended numeric value, field type, scale and range, browser or client, and parser version.
Method and evidence
Evidence type: Versioned locale-input contract, worked normalization example and sixteen executed deterministic parsing-decision fixtures
- Declared the accepted locale, decimal token, grouping token, sign rule, grouping rule, scale and range before transforming an input string.
- Validated the complete original string before removing one permitted grouping token and replacing one permitted decimal token; ambiguous or mixed conventions were rejected instead of guessed.
- Executed sixteen deterministic fixtures across en-US, de-DE and fr-FR inputs, invalid grouping, signs, empty and non-finite values, exponent notation, scale and range boundaries.
- Rechecked the HTML Living Standard, MDN's Intl.NumberFormat formatToParts reference and W3C form-validation guidance on 21 October 2026.
Topic score: 4.63 / 5. Business fit 4.8, verified demand 4.5, distinct intent 4.7, original evidence 4.8, citation usefulness 4.5, feasibility 4.3.
Primary sources
- HTML Living Standard: number input ↗Browser localization, valid floating-point representation and guidance on text controls for non-spinbox numeric input; standard updated 20 October 2026 and checked 21 October 2026.
- MDN: Intl.NumberFormat formatToParts ↗Reference for locale-formatted group, decimal, fraction and other output parts; checked 21 October 2026.
- W3C: Validating input ↗Accessible error feedback, forgiving format guidance and the need for server-side validation; checked 21 October 2026.
Limitations
- This reference covers three locale contracts with Latin digits; it does not certify every locale, numbering system, browser keyboard, assistive technology or currency convention.
- Spelled-out numbers, compact notation, scientific notation, accounting parentheses, bidirectional text and non-Latin digits are outside the executed fixtures.
- The parser rejects fractional scale over two instead of rounding it; products that round must publish and test a separate rounding policy.
- No named calculator builder, browser matrix, mobile keyboard, assistive technology or production user dataset was tested.
- The examples validate parsing decisions, not conversion-rate, completion-rate or revenue outcomes.
Verification and corrections
HTML number-input behavior, Intl.NumberFormat token behavior, W3C form-validation guidance and sixteen deterministic parsing fixtures verified 21 October 2026.
Recommended retest: Recheck after any locale, numbering-system, input-control, parser, scale, range, browser-support or error-recovery change.
Found an error or a changed standard? Use the correction process and include the page URL and primary evidence.
Next step
Apply the evidence to your next release
Use the published method, keep a dated test record and revisit the result after the calculator or its operating rules change.
Open the testing protocol