HTML | <input> pattern Attribute

The HTML <input> pattern attribute is used to specify the regular expression on which the input elements value is checked against. 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">

Example: This example illustrates the use of pattern attribute in <input> element.



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
    <head
        <title>
            HTML input pattern attribute
        </title
          
        <style
            body { 
                text-align:center; 
            
            h1 { 
                color:green; 
            
        </style
    </head
      
    <body
        <h1>GeeksforGeeks</h1
          
        <h2>HTML <input>pattern attribute</h2
          
        <form action="#"
            Password: <input type="text" name="Password"
              
            pattern="[A-Za-z]{3}" title="Three letter Password"
              
            <input type="submit"
        </form
    </body
</html>

chevron_right


Output:

Supported Browsers: The browser supported by HTML <input> pattern attribute are listed below:

  • Google Chrome 5.0
  • Internet Explorer 10.0
  • Firefox 4.0
  • Safari 10.1
  • Opera 9.6


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.