HTML <input> required Attribute
Example
<input type="text" id="fname" name="fname" required>
Meaning
The required is a Boolean attribute specifies that the form field must be set in order for form submission to proceed.
User agents that understand this should set the CSS pseudo-class :invalid when the field goes into error.
The required attribute works with the following input types: text, search, url, tel, email, password, date, number, checkbox, radio, and file
Standard Syntax
HTML: <input required>
XHTML: <input required="required" />
Advertisement
Attribute Values
| Value | Description |
|---|---|
| required | This is a boolean attribute, the presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value. |