Favorites

DOM HTMLInputElement.value Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
HTMLInputElement.value
DOM HTMLInputElement PropertyThis property is supported by all modern browsers.
Updated 28th November 2026

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 = text

Value

A string: the current value of the input.

Example

<input id="name" value="Sam">
<input id="qty" type="number" value="3">
const name = document.getElementById('name');
console.log(name.value, '|', name.getAttribute('value'));
name.value = 'Alex';
console.log(name.value, '|', name.getAttribute('value'));
const qty = document.getElementById('qty');
console.log(typeof qty.value, typeof qty.valueAsNumber);

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.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee