HTML | pattern Attribute
This attribute is used to specify the regular expression on which the input element value is checked. This attribute works with the following input types: text, password, date, search, email, etc. Use the Global title attribute to describe the pattern for helping the user.
Syntax:
<input pattern = "regular_exp">
Element: This attribute is associated with <input> element only.
Attribute: This attribute specifies the regular expression.
Example:
<!DOCTYPE html> <html> <head> <title>pattern attribute</title> <style> body { text-align:center; } h1 { color:green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>pattern attribute</h2> <form action="#"> Password: <input type="text" name="Password" pattern="[A-Za-z]{3}" title="3 letter Password"> <input type="submit"> </form> </body> </html> |
Output:

Supported Browsers: The browser supported by pattern attribute are listed below:
- Google Chrome 5.0 and above
- Internet Explorer 10.0 and above
- Firefox 4.0 and above
- Opera 9.6 and above
Recommended Posts:
- HTML | <input> pattern Attribute
- HTML | <img> src Attribute
- HTML | <img> alt Attribute
- HTML | dir Attribute
- HTML | <a> rel Attribute
- HTML | for Attribute
- HTML | low Attribute
- HTML | <map> name Attribute
- HTML | min Attribute
- HTML | <li> value Attribute
- HTML | value Attribute
- HTML | <dir> compact Attribute
- HTML | <th> colspan Attribute
- HTML | target Attribute
- HTML | <meter> low Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



