HTML <input> pattern Attribute

❮ HTML <input> tag


<form action="action.php">
  <label for="phone">Enter your phone number:</label>
  <input type="tel" id="phone" name="phone" pattern="[0-9]{3}-[0-9]{2}-[0-9]{5}">

  <input type="submit" value="Submit">


The pattern attribute specifies a regular expression against which the field should be validated.

The title attribute should be provided when this attribute is used, to give an indication of what is an acceptable pattern and what is not acceptable.

Standard Syntax

HTML: <input pattern="regexp">

XHTML: <input pattern="regexp"/>

Browser Support



Attribute Values

Value Description
regexp Specifies a regular expression the value must match to be valid.
❮ HTML <input> tag