Easy Tutorial
❮ Att Global Tabindex Att Tbody Charoff ❯

HTML <input> pattern Attribute

HTML <input> Tag

Example

An input field that can only contain three letters (no numbers or special characters allowed):


Browser Support

Internet Explorer 10, Firefox, Opera, and Chrome support the pattern attribute.

Note: Safari or Internet Explorer 9 and earlier versions do not support the pattern attribute of the <input> tag.


Definition and Usage

The pattern attribute specifies a regular expression that the <input> element's value is checked against.

Note: The pattern attribute works with the following input types: text, search, url, tel, email, and password.

Tip: Use the global title attribute to describe the pattern to help the user.

Tip: Learn more about regular expressions in our JavaScript tutorial.


Differences Between HTML 4.01 and HTML5

The pattern attribute is new in HTML5.


Syntax

Attribute Values

Value Description
regexp Specifies a regular expression that the <input> element's value is checked against.

❮ Att Global Tabindex Att Tbody Charoff ❯