Chapter 18. Forms and Form Fields

“I shall this very day, at Doctor’s feast, My bounden service duly pay thee. But one thing!—For insurance’ sake, I pray thee, Grant me a line or two, at least.”

Mephistopheles, in Goethe’s Faust

Forms were introduced briefly in the previous chapter as a way to submit information provided by the user over HTTP. They were designed for a pre-JavaScript Web, assuming that interaction with the server always happens by navigating to a new page.

But their elements are part of the DOM like the rest of the page, and the DOM elements that represent form fields support a number of properties and events that are not present on other elements. These make it possible to inspect and control such input fields with JavaScript programs ...

Get Eloquent JavaScript, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.