input required Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:input

Description

The required attribute is a boolean attribute to set if an input field must be filled out before submitting the form.

The required attribute works with the following input types: text, search, url, tel, email, password, date pickers, number, checkbox, radio, and file.

In XHTML, the required attribute must be defined as <input required="required" />.

Syntax

An HTML form with a required input field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php">
  Username: <input type="text" name="usrname" required>
  <input type="submit">
</form><!--from   w  w w  .jav  a2 s .c  o  m-->

</body>
</html>

Related Tutorials