Forms in JavaScript

Forms in JavaScript: Reading What People Type, Form Events, Canceling Events, Checking a Form with JavaScript.

Updated

  1. Reading What People Type (Apprentice): Read what a visitor typed, ticked and chose in a form with value and checked, turn text into numbers, and collect a whole form at once with form.elements or FormData.
  2. Form Events (Apprentice): Form controls send their own events, for the moments a visitor types, changes a value, moves between fields or sends the form, so you can pick the one that fires exactly when you need it.
  3. Canceling Events (Journeyman): A handler can cancel what the browser would do next, such as sending a form that failed validation, by calling preventDefault() on the event object the browser passes in.
  4. Checking a Form with JavaScript (Journeyman): Let the browser check a form with required, min and type, ask it in code with checkValidity(), add rules of your own with setCustomValidity(), and show each error next to its field where everyone, screen reader users included, can find it.