Skip to content

Don't suggest replacing numeric input with telephone input #42946

@RichardD2

Description

@RichardD2

MDN URL

https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Advanced_form_styling

What specific section or headline is this issue about?

Date input types : note

What information was incorrect, unhelpful, or incomplete?

The note in this section suggests replacing <input type="number"> with <input type="tel"> to get the numeric keypad on mobile devices.

Note: It is worth mentioning <input type="number"> here too — this also has a spinner that you can use to increment/decrement values, so potentially suffers from the same problem. However, in the case of the number type the data being collected is simpler, and it is easy to just use a tel input type instead, which has the appearance of text, but displays the numeric keypad in devices with touch keyboards.

However, unlike an <input type="number">, an <input type="tel"> will not validate that the entered value is numeric:

the input value is not automatically validated to a particular format before the form can be submitted, because formats for telephone numbers vary so much around the world.

What did you expect to see?

If the concern is to remove the spinner, then there is a CSS solution for that:

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    appearance: none;
    margin: 0;
}

input[type=number] {
    appearance: textfield;
}

And if you want a non-numeric input that shows the numeric keypad on mobile devices, it would be better to use the inputmode attribute:

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

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details

Metadata

Metadata

Assignees

No one assigned

    Labels

    Content:Learn:HTMLLearning area HTML docsgoal: best practices(Experimental label) Issues about content displaying unusual approaches.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions