required attribute | required property
When present, marks an element that can't be submitted without a value.
This property is read/write.
<element required="ptr" ... >
object.required = ptr ptr = object.required
A boolean attribute that designates an input field as requiring data.
- HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 184.108.40.206.6
The attribute can be set on text, text area, URL, email, select, checkbox, or radio button elements. It is a Boolean attribute and needs to be specified only on an element. When users hover the mouse over a required field, they’ll see a tool tip stating that it is a required field.
The following example shows the validation attribute on a text input field.