Chapter 7



Recipe 7.1
Populating a Form Field From Local Storage

Use the FormData API to populate a form field with a previously set value in local storage.

Recipe 7.2
Submitting a Form with Fetch and the FormData API

Use the Fetch API to submit a form, adding extra data with the FormData API.

Recipe 7.3
Submitting a Form as JSON

Use the FormData API to transform form data into JSON.

Recipe 7.4
Making a Form Field Required

Mark a form field as required with the "required" attribute.

Recipe 7.5
Constraining a Number Input

Limit the range of values that can be entered into a number input.

Recipe 7.6
Specifying a Validation Pattern

Use a regular expression based validation rule.

Recipe 7.7
Validating Forms

Use the Constraint Validation API to check the validity of form fields.

Recipe 7.8
Using Custom Validation Logic

Use the setCustomValidity function to apply a custom validation message.

Recipe 7.9
Validating a Checkbox Group

Validate that at least one option is selected in a group of checkboxes.

Recipe 7.10
Validating a Field Asynchronously

Perform asynchronous validation with a network request.

Web Browser API Cookbook
Joe Attardi