required attribute | required property
When present, marks an element that can't be submitted without a value.
This property is read/write.
![]() ![]() |
Syntax
| HTML |
|---|
<element required="ptr" ... > |
| JavaScript |
|---|
object.required = ptr ptr = object.required |
Property values
Type: boolean
A boolean attribute that designates an input field as requiring data.
Standards information
- HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 4.10.7.3.6
Remarks
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.
<p><label>Name: <input type="text" required /></label></p>
See also
Show:

