The pattern Attribute

The pattern Attribute

<pre><code>//an input field that can contain only three letters (no numbers or special characters)

Country code: &lt;input type=&quot;text&quot; name=&quot;country_code&quot; pattern=&quot;[A-Za-z]{3}&quot; title=&quot;Three letter country code&quot;&gt;</code></pre>

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

Works with the following input types: text, search, url, tel, email, and password.

Related concepts

The pattern Attribute — Structure map

Clickable & Draggable!

The pattern Attribute — Related pages: