Chapter 8: Forms

Forms are a very common method of interacting with a web page. A form is the main component of Google’s home page, and most of us use forms every day to log in to our favorite sites. In this chapter, we will look at how forms can be used to interact with a JavaScript program.

In this chapter, we’ll cover these topics:

  • Form controls

  • Accessing form elements

  • Form properties and methods

  • Form events

  • Submitting a form

  • Retrieving and changing values from a form

  • Form validation

  • Our project ― add a form for answering the questions.

Forms

Forms are made up of a <form> element that contains form controls such as input fields, select menus and buttons. These input fields can be populated with information that is processed once ...

Get JavaScript: Novice to Ninja, 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.