HTML DOM Input Text object
Input Text object
The Input Text object represents the element of the html type-"text".
Access the Input Text object
You can access the type-"text" element through getElementById():
Tip: Similarly, you can access the Input Text object by looking up the form elements collection.
Create an Input Text object
You can create the type-"text" element by document.createElement() method:
x.setAttribute("type", "text"); Give it a try
Input Text object properties
Property | Describe |
---|---|
autocomplete | Set or return the autocomplete property value for the text field |
autofocus | Whether the text field is set or returned after the page is loaded automatically gets focus |
defaultValue | Set or return the default value for the text field |
disabled | Set or return whether the text field is disabled |
form | Returns a reference to a form object that contains a text field |
list | Returns a reference to an option list object that contains a text field |
maxLength | Sets or returns the maximum number of characters in the text field |
name | Set or return the name of the text field |
pattern | Set or return the pattern property value of the text field |
placeholder | Set or return the placeholder property value for the text field |
readOnly | Set or return whether the text field should be read-only |
required | Set or return if text field must be filled out before submitting a form |
size | Set or return the size property value of the text field |
type | Returns the type of form element for the text field |
value | Set or return the value property value of the text field |
Input Text object method
Method | Describe |
---|---|
blur() | Remove the focus from the text field |
focus() | Let the text field get the focus |
select() | Select the contents of the text field |
Standard properties and events
Input Text objects also support standard properties and events.
Related pages
HTML tutorial: HTML forms
HTML Reference Manual: HTML slt;input.gt; Tags
HTML Reference Manual: HTML slt;input> type property