Formatting
Formatting groups the digits of the value with thousand separators. groupingStyle defaults to 'thousand', and 'none' turns grouping off. Formatting runs on every keystroke by default, or only on blur with 'blur'. Numora keeps the cursor in place either way.
Grouping styles
Groups of 4 from the right.
When to format
The separators appear on every keystroke by default, or only on blur with formatOn: 'blur'. See Change vs blur for both modes.
Caret position
When the separators move, the caret stays between the same two digits:
Naive formatter
123,845,679
NumoraInput
123,894,567
The 9 lands at the end in naive. Numora puts it after the 8.
Without that, a production app looks like this:
Separator skipping
- Backspace and Delete jump over thousand separators, so you never delete one by hand.
- This applies with
formatOn: 'change', a thousand separator set and no text selected. In blur mode a focused field has no separators to skip. - Two handlers share the work.
keydownmoves the cursor over the separator, andbeforeinputdeletes the digit. Mobile keyboards that send no usablekeydownstill work, becausebeforeinputthen deletes the digit past the separator itself.
Backspace after a comma
With Numora
beforeinput then deletes the 1.