Easy Tutorial
❮ Prop Date Readonly Jsref Gettime ❯

HTML DOM Input Text Object


Input Text Object

The Input Text object represents an HTML <input> element with type="text".

Accessing an Input Text Object

You can access an <input> element with type="text" by using getElementById():

Tip: Similarly, you can access an Input Text object by searching the form's elements collection.

Creating an Input Text Object

You can create an <input> element with type="text" by using the document.createElement() method:

Input Text Object Properties

Property Description
autocomplete Sets or returns the value of the autocomplete attribute of the text field
autofocus Sets or returns whether the text field should automatically get focus when the page loads
defaultValue Sets or returns the default value of the text field
disabled Sets or returns whether the text field is disabled
form Returns a reference to the form that contains the text field
list Returns a reference to the datalist that contains the text field
maxLength Sets or returns the maximum number of characters allowed in the text field
name Sets or returns the name of the text field
pattern Sets or returns the value of the pattern attribute of the text field
placeholder Sets or returns the value of the placeholder attribute of the text field
readOnly Sets or returns whether the text field should be read-only
required Sets or returns whether the text field must be filled out before submitting the form
size Sets or returns the value of the size attribute of the text field
type Returns the type of the form element
value Sets or returns the value of the value attribute of the text field

Input Text Object Methods

Method Description
blur() Removes focus from the text field
focus() Gives focus to the text field
select() Selects the content of the text field

Standard Properties and Events

The Input Text object also supports the standard properties and events.


Related Pages

HTML Tutorial: HTML Forms

HTML Reference: HTML <input> Tag

HTML Reference: HTML <input> type Attribute

❮ Prop Date Readonly Jsref Gettime ❯