English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The input required attribute is a boolean attribute. If the required attribute exists, it specifies that the input field must be filled out before submitting the form.
HTML form with a required input field:
<!DOCTYPE html> <html> <head> <title>HTML: <input> required Attribute - Basic Tutorial Website(oldtoolbag.com)</title> <body> <form action="action_page.php"> Username: <input type="text" name="usrname" required> <input type="submit"> </form> </html>Test to see ‹/›
The numbers in the table indicate the first browser version that supports the attribute.
Attribute | |||||
---|---|---|---|---|---|
required | 5.0 | 10.0 | 4.0 | 5.0 | 9.6 |
The required attribute is a boolean attribute.
If the required attribute exists, it specifies that the input field must be filled out before submitting the form.
Note:The required attribute applies to the following input types: text, search, url, tel, email, password, date pickers, number, checkbox, radio, and file.
The required attribute is in HTML5 . New attributes added.
In XHTML, attribute abbreviations are prohibited, the required attribute must be defined as <input required="required" />.
<input required>HTML <input> tag