
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Input Search pattern property
The HTML DOM Input Search pattern property is used for setting or returning the pattern attribute of an input search field. It checks the search field time against a regular expression that is specified by the pattern property.
Syntax
Following is the syntax for −
Setting the pattern property −
searchObject.pattern = regexp
Here, regexp is a regular expression against which the search field is checked.
Example
Let us look at an example for the Input Search pattern property −
<!DOCTYPE html> <html> <body> <h1>Input Search pattern property</h1> <p>The time inside search field can either be of three numeric characters or 6 alphabet characters from a to g</p> <form action="/Sample_page.php"> FRUITS: <input type="search" id="SEARCH1" name="fruits" pattern="[0-9]{3}|[a-g]{6}" title="Three numeric character or 6 alphabet between a-g"> <input type="submit"> </form> <br> <button onclick="passPattern()">GET PATTERN</button> <p id="Sample"></p> <script> function passPattern() { var P = document.getElementById("SEARCH1").pattern; document.getElementById("Sample").innerHTML ="The pattern attribute value is"+ P; } </script> </body> </html>
Output
This will produce the following output −
On entering text inside search field that is not matched by regex specified in the pattern property −
On clicking the GET PATTERN button −
- Related Articles
- HTML DOM Input Password pattern property
- HTML DOM Input Email pattern Property
- HTML DOM Input URL pattern Property
- HTML DOM Input Text pattern property
- HTML DOM Input Search autocomplete Property
- HTML DOM Input Search autofocus Property
- HTML DOM Input Search defaultValue Property
- HTML DOM Input Search disabled Property
- HTML DOM Input Search form Property
- HTML DOM Input Search maxLength Property
- HTML DOM Input Search name Property
- HTML DOM Input Search placeholder property
- HTML DOM Input Search readOnly property
- HTML DOM Input Search required property
- HTML DOM Input Search size property

Advertisements