CKTIS / JavaScript
HTMLInputElement.value — reading and writing an input value
HTMLInputElement.value reads or sets a value as a string. Its behavior depends on type; for a text input, the current value can differ from the default value.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
input.value
input.value = "new value";HTMLInputElement.value is a Web API property, not part of ECMAScript itself. It returns a string, even for type="number"; use valueAsNumber to read a number. It requires a browser DOM environment, not Node.js alone.
For a text input, .value means the current value. defaultValue reflects the HTML value attribute. Assigning .value sets an internal dirty value flag: subsequent attribute changes no longer update the current value until that flag is reset, for example by resetting the form. Assignment does not automatically fire input or change events.
The browser applies type-specific sanitization rules: an invalid numeric value can become "". For checkboxes and radio buttons, .value specifies the submitted value, defaulting to "on", not whether the control is selected — read checked for that.
For type="file", use files to access files. .value does not reveal the real path; assigning a nonempty string throws InvalidStateError, while "" clears the selection.
Examples
const input = document.createElement("input");
input.type = "text";
input.defaultValue = "Ada";
input.value = "Lin";
console.log(JSON.stringify({
value: input.value,
defaultValue: input.defaultValue,
attribute: input.getAttribute("value")
}));Result
{"value":"Lin","defaultValue":"Ada","attribute":"Ada"}The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.