DOM HTMLInputElement.value Property
The value property gets or sets the current value of an input field, such as the text a user has typed.
Description
The value property returns the current value of the input as a string, and setting it changes what's shown. For number and date inputs, valueAsNumber and valueAsDate return typed values. Note the difference from the value attribute, which only sets the initial value; getAttribute('value') doesn't change as the user types. Setting value from script doesn't fire input or change events.
For file inputs, value returns a fake path such as C:\fakepath\photo.jpg for security reasons, and can only be set to an empty string; use the files property to read the chosen files. For checkboxes and radios, value is the value sent with the form, not whether the box is checked.
The defaultValue property reflects the value attribute, so comparing value with defaultValue tells you whether the user has changed a field, which is useful for "unsaved changes" warnings.
Syntax
input.value
input.value = textValue
A string: the current value of the input.
Example
Browser Support
The following information will show you the current browser support for the HTMLInputElement.value property. Hover over a browser icon to see the version that first introduced support for this property.
Desktop





Tablets & Mobile





