<input> - search


HTML DOM Input Search object


Input Search object

The Input Search object is new to HTML5.

The Input Search object represents an HTML <input> element with type="search".

Access the Input Search object

You can use the getElementById() function to access <input> elements with the type="search" attribute:

var x = document.getElementById("mySearch");

 Try It! 

Tip: You can also access the Input Search object through the form's elements collection.

Create an Input Search object

You can use the document.createElement() method to create an <input> element with the type="search" attribute:

var x = document.createElement("INPUT");
x.setAttribute("type", "search");

 Try It! 

Input Search Object Attributes

AttributeDescription
autocompleteSets or returns the autocomplete attribute value for the search field
autofocusSets or returns whether the search field automatically gets the focus after the page loads
defaultValueSets or returns the default value of the search field
disabledSets or returns whether the search field is available
formReturns a form reference that uses the search field
listReturns a form reference a that uses the search field
maxLengthSets or returns the maxLength attribute value for the search field
nameSets or returns the value of the name attribute of the search field
patternSets or returns the pattern attribute value of the search field
placeholderSets or returns the value of the placeholder attribute of the search field
readOnlySets or returns whether the search field is read-only
requiredSets or returns whether the search field is required in the form
sizeSets or returns the size attribute value of the search field
stepSets or returns the value of the step attribute of the search field
typeReturns the form element type of the search field
valueSets or returns the value of the value attribute of the search field

Standard Properties and Events

The Input Search object also supports standard properties and events .


Related articles

HTML Tutorial: HTML Forms

HTML Reference Manual: HTML <input> Tag

HTML Reference Manual: HTML <input> type attribute