HTML input required attributes
Examples
HTML form with the required fields:
<form action="demo_form.html">
Username: <input type="text" name="usrname" required>
<input type="submit">
</form>
Username: <input type="text" name="usrname" required>
<input type="submit">
</form>
try it"
Browser Support
Internet Explorer 10, Firefox, Opera and Chrome support required attributes.
Note: Safari or Internet Explorer 9 and earlier versions do not support the required attributes <input> attribute.
Definition and Usage
required attribute is a Boolean attribute.
required attribute specifies the input fields must be filled in before submitting the form.
Note: required attributes apply to the following input types: text, search, url, tel , email, password, date pickers, number, checkbox, radio and file.
Differences between HTML 4.01 and HTML5
required attribute is new in HTML5 attributes.
Differences between HTML and XHTML
In XHTML, prohibit attribute minimization, required attributes must be defined as <input required = "required" />.
grammar
<input required>
HTML <input> tag