# Right phone keyboard for every form field

> Use type and inputmode to show the right virtual keyboard: numeric for codes, tel for phones, email for addresses.

Source: https://fullbytedeveloper.com/blog/mobile-keyboard-input-types
Keyword: PHONEKEYS
Published here: 2026-11-10

The wrong keyboard makes mobile forms frustrating. Here is which combination of `type` and `inputmode` to use for each field.

## Email address

Use `type="email"`. The keyboard shows @ and common domain suffixes [3]:

```html
<input type="email" name="email" autocomplete="email">
```

## Phone number

Use `type="tel"`. The keyboard shows a phone dialpad [3]:

```html
<input type="tel" name="phone" autocomplete="tel">
```

## Credit card number

Use `type="text"` with `inputmode="numeric"`. This shows a number pad without the spinner buttons that `type="number"` adds [1] [2]:

```html
<input type="text" inputmode="numeric" pattern="[0-9 ]{13,19}" autocomplete="cc-number">
```

## ZIP or postal code

Same pattern: `type="text"` with `inputmode="numeric"` [2]:

```html
<input type="text" inputmode="numeric" pattern="[0-9]{5}" autocomplete="postal-code">
```

## One-time code (OTP)

Use `inputmode="numeric"` and `autocomplete="one-time-code"` so the device offers to autofill from SMS:

```html
<input type="text" inputmode="numeric" autocomplete="one-time-code" pattern="[0-9]{6}">
```

## Decimal amount (price, weight)

Use `inputmode="decimal"`. The keyboard includes a decimal separator [1]:

```html
<input type="text" inputmode="decimal" pattern="[0-9]*\.?[0-9]*">
```

## URL

Use `type="url"`. The keyboard shows / and .com shortcuts [3]:

```html
<input type="url" name="website" autocomplete="url">
```

## When to use type=number

Only for values that make sense to increment: quantity selectors, age inputs, or numeric settings. The spinner buttons are part of the UI [2].

```html
<input type="number" name="quantity" min="1" max="99">
```

For codes, IDs, and formatted numbers, use `inputmode="numeric"` instead.

Send this to the friend whose signup form shows a letter keyboard for a phone number.

## Sources

1. [MDN: inputmode attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/inputmode)
2. [web.dev: form attributes in depth](https://web.dev/learn/forms/attributes)
3. [MDN: HTML5 input types](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/HTML5_input_types)
