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 ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.