Feet and inches input on iPhone

A real bug we shipped: measurement fields on our calculator site could not be filled in on an iPhone.

What happened

We build calculators where people type room sizes the way a tape measure reads: 12' 6", 11 3/4, 10x20. To show a friendly keypad on phones, the length fields had inputmode="decimal". On a real iPhone that opens the decimal pad: ten digits and a point. No apostrophe, no quote mark, no space, no slash, no x. The examples on the page were impossible to type. Desktop tests passed, because a computer keyboard has every key. It took a real phone to see it.

The fix was to remove inputmode from every length field so the standard keyboard opens. Price and percentage fields kept the decimal pad, because they only ever need digits and a point.

Inputs that work for measurements

One field, standard keyboard

<label for="len">Length</label>
<input id="len" type="text" placeholder="12' 6" or 12.5"
       autocapitalize="none" autocorrect="off" spellcheck="false">

Parse feet, inches and fractions yourself. Accept ' and " as well as ft and in, smart quotes (’ ”) that the iPhone keyboard inserts, and fractions such as 1/2 or the single character ½.

Two fields, number pads

<fieldset><legend>Length</legend>
  <label>Feet <input type="text" inputmode="numeric"></label>
  <label>Inches <input type="text" inputmode="decimal"></label>
</fieldset>

Separate feet and inches fields let both use number pads. You lose fractions like 3/8 unless you accept decimals (0.375) or add a fraction picker.

Watch for smart punctuation

With Smart Punctuation on, which is the iPhone default, typing ' and " produces curly ’ and ”. A parser that only looks for straight quotes rejects them. Normalize both before parsing.

Test the placeholder

A good rule: every example in your placeholder or help text must be typeable on the keyboard the field opens. The checker tests exactly that.

Frequently asked questions

Can I type a fraction on the iPhone decimal pad?

No. The decimal pad has no slash or space. Use the standard keyboard or accept decimals.

Why does my parser fail on iPhone but not on a computer?

Usually smart quotes: the iPhone turns ' and " into ’ and ”. Convert them before parsing.

Found a mistake or want a check added? Write to contact (at) mobileformcheck.com.