Guided Notes

Forms, Validation & Storage

Reading form values, handling submit, validating input, showing messages, and saving data with localStorage.

Reading form values

Slide 1 / 5

Inputs expose what the user typed through .value (always a string):

const email = document.getElementById('email').value.trim(); const age = Number(document.getElementById('age').value);

Checkboxes use .checked (true/false); a <select> uses .value for the chosen option.

new FormData(form) collects every named field at once: Object.fromEntries(new FormData(form)) turns it into a plain object.

← Events