pattern

Specifies a regular expression that the <input> element's value is checked against. The browser will not allow the form to submitted if the <input> value does not pass this check.

The value used for this property is actually a partial regular expression. A regular expression is normally used to find a bit of text in a larger string. For validation purposes, this pattern must match the whole value, not just a substring. To achieve this, the pattern is modified to anchor it to the beginning and end of the value by adding ^(?: to the beginning of the pattern and )$ to the end.

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

Default value

Blank

Valid values

A valid JavaScript regular expression.