REQUIRE A VALUE IN AN INPUT FIELD

You can use the new required input attribute to force the user to supply a value in any input field. Supported web browsers will pop up a simple message saying that the field is required if the user attempts to submit a blank value:

<input ... required>

The required attribute, when applied to an input element, activates the require-input feature in the user’s web browser, if supported.

One unfortunate problem with the require-input feature is that if multiple fields are required and missing a value, only the first one will receive the pop-up notification error. The user will need to correct the first problem and submit the form again before being notified of the second error.

To sidestep this issue, simply ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications 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.