HTML5 Telelephone Input Type

HTML5 introduced new input type targated to collect a telephone number. As you know, telephone number format differs around the world. You can not guarantee any specific type of notation except for allowing only numbers and perhaps a plus symbol. If you had worked with earlier versions of HTML you would have written custom phone number validation in Javascript.

Well, now you don't need to worry about it. HTML5 makes your development life easier, in order to achieve this, you just have to add type="tel" in your input element, rest HTML5 will take care for you.

Syntax

Here is a simple demo.

As of writing, only few browsers provide support for this new feature.

Browser Supports

If you want to make your textbox self explanatory, you can use additional attribute "Placeholder" by assigning meaningful text. The "placeholder", in the phone textbox example,will looks like this:

Syntax

Here is a simple demo.

Example

See Live Example