element.value Form element value
Last updated: 2026-09-09
element.value Form element value
value gets or sets the current value of form elements.
| Category | DOM |
|---|---|
| ES version | DOM |
📝 Syntax
const val = input.value;
Returns:The form element's value (string).
Mutates the original:Yes (in place)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
(current value)
💡 Tip Always trim() user input before validation.
ℹ️ info Use checked (boolean) for checkboxes, not value.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| element.value | ✓ v1 | ✓ v12 | ✓ v1 | ✓ v1 | ✓ v1 |
| Supported by all modern browsers | |||||
🏷️ Related Items
💡 Related Cases
More case studies coming soon — check back later.
📚 Related Tutorials
❓ FAQ
Qvalue vs textContent?
Avalue for form elements; textContent for regular elements.
QHow to get checkbox value?
AUse checkbox.checked (boolean).
QCan value set select selection?
AYes — setting select.value selects the matching option.