Last Updated : Jul 1, 2023
The value property includes the user's entered value OR the default value (or a value set by a script).
The text value property can be used to set and get the value of such a textual field's value attribute.
The value of an input field's value attribute can be changed or returned using the text value property.
The Input Text Field's initial value is defined by the value attribute. It includes either the user's input or the default value.
- We use <!DOCTYPE HTML> at the beginning of our code. The HTML doctype element is used to specify which version of HTML a document is using. A document type declaration is what is used to describe this (DTD).
- Next, we employed HTML and HEAD tags, and the TITLE tag was used to provide the title for the web page.
- Next, we begin writing the actual code that will be shown on the website using the BODY tag.
- Next, we utilise the INPUT text tag with placeholder attribute to specify a brief description of the intended value of an input field. A quick message is displayed in the input box prior to the user entering a value.
- Id and class are also used as inputid and inputclass, respectively.
- Following that, we begin our script and call the getinputvalue method ().
- After that, the value attribute is obtained using getElementsByClassName and the getInputValue() function.
- The text input field's value can be obtained using getElementsByClassName. It gives back the group of elements that the class name specifies. The document element is used to call the getElementsByClassName() function.
- The class name is represented by inputClass. If there are no matching elements,  means to return undefined.
- After that, we use an alert to show that value. Finally, we use SCRIPT, BODY, and HTML elements to wrap up our code.
We also discovered that the set of elements given by the class name is returned by the getElementsByClassName() method.
And With the text value property, one can modify or retrieve the value of such an inputs field's value attribute.
The value attribute specifies the default value for the Input Text Field. Either the default value or the user's input is included.