Share
pattern Attribute
The pattern attribute specifies a pattern used to validate an input field.
The pattern is a regular expression. You can read about this in our
JavaScript tutorial.
Note: The pattern attribute works with the following <input> types: text, search, url, telephone, email, and password
The example below shows a text field that can only contain three letters (no numbers or special characters):
Country code: <input type="text" name="country_code" pattern="[A-z]{3}" title="Three letter country code" />