HTML | DOM Input Text Object Last Updated : 26 Aug, 2022 Comments Improve Suggest changes Like Article Like Report The Input Text Object in HTML DOM is used to represent the HTML <input> element with type="text" attribute. The <input> element with type="text" can be accessed by using getElementById() method. Syntax: It is used to access input text object. document.getElementById("id");It is used to create input element. document.createElement("input"); Input Text Object Properties: PropertyDescriptiontypeIt is used to return the type of form element to the text field.valueThis property is used to set or return the value of the value attribute of the text field.autocompleteThis property is used to set or return the value of the autocomplete attribute of a text field.autofocusThis property is used to set or return whether a text field should automatically get focus when the page loads.defaultValueThis property is used to set or return the default value of a text field.disabledThis property is used to set or return whether a text field is disabled or not.formThis property is used to return reference to the form that contains the text field.listThis property is used to return a reference to the datalist that contains the text field.maxLengthThis property is used to set or return the value of the maxlength attribute of a text field.nameThis property is used to set or return the value of the name attribute of a text field.patternThis property is used to set or return the value of the pattern attribute of a text field.placeholderThis property is used to set or return the value of the placeholder attribute of a text field.readOnlyThis property is used to set or return whether the text field is read-only or not.requiredThis property is used to set or return whether the text field must be filled out before submitting a form.sizeThis property is used to set or return the value of the size attribute of the text field. Methods focus() : It is used to get focus to the input text field.blur () : It is used to remove focus from the text field . select () : It is used to select the content of the Input text field. Example 1: This example use getElementById() method to access <input> element with type="text" attribute. HTML <!DOCTYPE html> <html> <head> <title> HTML DOM Input Text Object </title> </head> <body> <h1>GeeksForGeeks</h1> <h2>DOM Input Text Object</h2> <input type="text" id="text_id" value="Hello Geeks!"> <p>Click on button to display the text field</p> <button onclick="myGeeks()">Click Here!</button> <p id="GFG"></p> <!-- script to access text field --> <script> function myGeeks() { var txt = document.getElementById("text_id").value; document.getElementById("GFG").innerHTML = txt; } </script> </body> </html> Output: Before click on the button: After click on the button: Example 2: This example use document.createElement() method to create <input> element with type="text" attribute. HTML <!DOCTYPE html> <html> <head> <title> HTML DOM Input Text Object </title> </head> <body> <h1>GeeksForGeeks</h1> <h2>DOM Input Text Object</h2> <p>Click the button to create Text Field</p> <button onclick = "myGeeks()"> Click Here! </button> <!-- script to create th element --> <script> function myGeeks() { /* Create an input element */ var x = document.createElement("INPUT"); /* Set the type attribute */ x.setAttribute("type", "text"); /* Set the value to the attribute */ x.setAttribute("value", "Hello Geeks!"); /* Append node to the body */ document.body.appendChild(x); } </script> </body> </html> Output: Before click on the button: After click on the button: Supported Browsers: Google Chrome 1 and aboveEdge 12 and aboveMozilla Firefox 1 and aboveOperaSafari 1 and above Comment More infoAdvertise with us D divyatagoel0709 Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML | DOM Textarea rows Property The DOM Textarea rows Property is used to set or return the value of a rows attribute of a textarea field. The rows attribute specifies the number of visible text lines for the control i.e the number of rows to display. Syntax: It is used to Return the rows property:textareaObject.rowsIt is used to 2 min read HTML DOM Video Object The Video object in HTML DOM represents an <video> element. The video element can be accessed by using getElementById() method. Syntax: To access a video object: document.getElementById("videoId");where id is assigned to the <video> tag.To create a video object: document.createElement("V 4 min read HTML | DOM Input Month Object The Input Month Object in HTML DOM is used to represent an HTML input element with type= "month" attribute. The input element with type= "month" attribute can be accessed by using getElementById() method. Syntax: It is used to access <input> element with type="month" attribute.document.getElem 3 min read HTML | DOM Style flexGrow Property The HTML DOM style flexGrow property is used as a measure to determine how much an item will grow relative to the rest of the flexible items inside the same container. Syntax: Return flexGrow property:object.style.flexGrowSet flexGrow property:object.style.flexGrow = "number|initial|inherit" Propert 3 min read HTML | DOM Input Email Object The Input Email Object in HTML DOM is used to represent the HTML input element with type="email" attribute. The input element with type="email" attribute can be accessed by using getElementById() method. Syntax: It is used to access input email object.document.getElementById("id");It is used to crea 3 min read HTML | DOM Storage setItem() Method The setItem() method is used to set the storage object item which is specified by the user. This storage object can be a localStorage object or sessionStorage object. Syntax: For local storage: localStorage.setItem(keyname, value) For session storage: sessionStorage.setItem(keyname, value) Parameter 1 min read HTML | DOM Textarea required Property The DOM Textarea required Property is used to set or return the Whether that the input element must be filled out before submitting the Form. This Property is used to reflect the HTML required attribute.Syntax: It is used to Return the required property: textareaObject.requiredIt is used to Set the 2 min read HTML | DOM Style verticalAlign Property This property is used to set or return the vertical alignment of the content in an element. Syntax: Return VerticalAlign :object.style.verticalAlignSet VerticalAlign :object.style.verticalAlign = value Properties: ValueDescriptionlengthIt is used to raise or lower an element by some given length.%It 4 min read HTML | DOM Input Datetime Object The Input Datetime Object in HTML DOM is used to represent an HTML input element with type= "datetime". The input element with type= "datetime" can be accessed by using getElementById() method. Syntax: It is used to access input Datetime object.document.getElementById("id");It is used to create inpu 3 min read HTML | DOM Storage getItem() Method The getItem() method is used to retrieve the storage object which is specified by the user. This storage object can be localStorage object or sessionStorage object. Syntax:Parameters: It requires Keyname which specifies name of the key used for getting the value. Return Value: A String, representing 1 min read Like