Interactive demo

Explore numeric input problems

Seven ways a numeric input breaks in a web app. Try each demo, then you'll see why Numora exists.

Problem 1

Paste chaos

Users paste numbers in whatever format they have

Real users paste values from spreadsheets, financial reports, different locales, and scientific tools. Native inputs reject them or corrupt the value without telling you. Press a paste button to see it.

Native <input type="number">
Numora
Problem 2

Cursor position hell

Formatting moves the cursor

Add commas to a number as it is typed and the cursor jumps to the end. Type 1234567 quickly in both inputs and watch the cursor.

Naive formatting

Type rapidly and watch the cursor jump to the end after each keystroke:

_

Cursor at position: 0

The cursor jumps to the end every time, so you can't edit the middle.

Numora

Type quickly. The cursor stays where it belongs:

_

Cursor at position: 0

The cursor stays put, even as Numora adds commas.

Problem 3

Scientific notation expansion

1e-18 should expand to 0.000000000000000001

DeFi amounts are often very small or very large. Pasting 1e-18 (1 wei) should show the full decimal, not scientific notation.

1 wei
Input:1e-18
Output:0.000000000000000001
Lab measurement
Input:1.5e-7
Output:0.00000015
Large number
Input:2.1e+15
Output:2100000000000000
Native <input type="number">

Native value:

(empty)

Shows scientific notation or loses precision

Numora

Numora expands:

(empty)

Full decimal expansion, no precision lost

Problem 4

Mobile keyboard gremlins

Invisible characters that break validation

Mobile keyboards can insert non-breaking spaces (U+00A0), zero-width characters and other invisible Unicode. Validation and math then fail with no visible cause.

The hidden character problem

When copying "1 234" from a mobile app, you might get:

What you see:

1 234

What's actually there (UTF-8 bytes, hex):

31 C2 A0 32 33 34

(C2 A0 = UTF-8 non-breaking space)

Native input
Numora
Problem 5

The decimal dilemma

Is 1,234 one thousand or 1.234?

In the US, 1,234.56 means one thousand two hundred thirty-four and 56 cents. In Europe, the same number is written as 1.234,56. A native input can't tell which one you mean.

Select locale format:

Try typing 1.2.3.4 or1,2,3,4 to see what happens with repeated separators.

Valid for US:

1,234.56

Confusing for US:

1.234,56
Native <input type="number">

Type 1,234.56:

A native input rejects commas and has no locale setting.

Numora

Type 1,234.56:

You set the decimal separator. Numora keeps the first decimal separator and drops the rest.

Problem 6

Thousand separator traps

Format on blur is jarring. Format on change is hard

Adding thousand separators while someone types is hard. Most implementations format on blur, which jars, or on change, which moves the cursor. Regions also group digits differently.

Grouping style:
Naive format-on-change

Type 1234567 and watch the cursor:

Problems:

  • Cursor jumps to end after each keystroke
  • Editing in the middle is impossible
  • Only supports one grouping style
Numora

Type 1234567 the same way:

Features:

  • The cursor stays in place
  • You can edit anywhere in the number
  • Supports Thousand grouping: 1,234,567
Problem 7

The type="number" lie

It looks right, but it isn't

<input type="number"> looks like the obvious choice for a numeric input. It has problems that make it a poor fit for money.

Scroll wheel changes value

Scrolling over the input changes the number

Can't format with commas

It rejects thousand separators

Shows spinners on desktop

Increment and decrement buttons show up

Inconsistent validation

Allows "e" but not ","

Poor accessibility

Screen readers handle it inconsistently

Mobile keyboard issues

Some mobile browsers show the wrong keyboard

Value vs display mismatch

.value can differ from the text on screen

type="number"

Hover over the input and use your scroll wheel:

Try this:
  • Hover and scroll to change the value by accident
  • Try typing 1,000 (comma rejected)
  • Look at the spinner buttons

Implementation:

<input type="number" />
Numora (type="text" + inputmode)

Same test. Hover and scroll:

Numora uses:

  • type="text", so scrolling does nothing
  • inputmode="decimal" for the numeric keyboard on mobile
  • Commas and other separators
  • Numora sanitizes pasted values before they reach your state

Implementation:

<input type="text" inputmode="decimal" />

Fix these in your app

Numora handles every case on this page. Values stay strings, so nothing loses precision, and the cursor stays where you left it.