Skip to content

Lesson 04 · The DOM

Forms & Validation in the Browser

Read form values at the right moment, handle submit without a page reload, validate with the constraint validation API, give feedback people can perceive, and collect everything with FormData.

40 minintermediateThe DOM & Browser APIs

Prerequisites: Events: Responding to Your User

Learning objectives
By the end of this lesson, you will be able to:
  • Read text, checkbox and select values, and choose between input and change by intent
  • Handle the submit event with preventDefault instead of a page reload
  • Validate with constraints, checkValidity, validationMessage and setCustomValidity
  • Give inline feedback with aria-invalid, error regions and focused first errors
  • Collect every field at once with the FormData API