Form Elements & Data in JavaScript

From the DOM Manipulation cheat sheet · Forms · verified Jul 2026

Form Elements & Data

Access and manipulate form elements and their values

javascript
// Get form and elements
const form = document.getElementById('myForm')
const input = form.elements['username']
const inputs = form.elements  // All form controls

// Get values
const value = input.value
const checked = checkbox.checked
const selected = select.value

// FormData API
const formData = new FormData(form)
const username = formData.get('username')
💡 FormData makes form handling much easier
📌 form.elements provides easy access to inputs
⚡ Use checkValidity() for HTML5 validation
✅ Always preventDefault() on form submit for SPA

Continue with DOM Manipulation

Save the full cheat sheet or work through every related task.

More JavaScript tasks

Back to the full DOM Manipulation cheat sheet