Use tel input to get user telephone number

Description

The tel type value configure the input element to accept only input that is a telephone number.

It supports the additional attributes shown in the following list.

  • list - Sets the id of a datalist element that provides values for the element.
  • maxlength - Specifies the maximum length that the user can enter into the text box.
  • pattern - Specifies a regular expression pattern for input validation.
  • placeholder - Specifies a hint to the user.
  • readonly - If present, make the text box read-only.
  • required - Specifies that the user must provide a value.
  • size - Specifies the width of the element.
  • value - Specifies the initial value for the element.

Example


<!DOCTYPE HTML>
<html>
<body>
  <form method="post" action="http://example.com/form">
<!--from w w w. j a  v  a2  s  . co  m-->
    <p>
      <label for="tel"> Tel: <input type="tel"
        placeholder="(XXX)-XXX-XXXX" id="tel" name="tel" />
      </label>
    </p>
    <input type="submit" value="Submit Vote" />
  </form>
</body>
</html>

Click to view the demo





















Home »
  HTML CSS »
    HTML »




HTML Introduction
HTML Document
HTML Section
HTML Group Content
HTML Text Marker
HTML Table
HTML Form
HTML Embed