required
Definition and Usage
The required attribute is a boolean attribute. When present, it specifies the user is required to select a value before submitting the form. It specifies that the user is required to select an option before submitting the form.We’ll use the required
attribute to indicate that we need the user to provide the information requested by this control. When this attribute present, and the control is in the drop-down mode, authors must provide a placeholder label option, which is nothing but a first option
that when selected, indicates that no real option
has been selected in the control. This option
must be the first in the control, its value
attribute must be empty and it musn’t belong to any optgroup
.
When the required
attribute is present, supporting browsers prevent the submission of the form
until one or more options in this control have been properly selected.
Possible values:
- [Empty string]
- required