HTML required attribute

required attributes forces the user to enter a value in the input field.

<form action="files/required.php" method="post">
  Name:<input type="text" name="fullname">
  Email: <input type="email" name="user-email" required>
  <input type="submit" name="submit">
 </form>
</>
Name: Email:

Attribute values

All possible values of required attribute

required attribute is a boolean attribute.

Related Tags

The tags that support required attribute

<input>

This element allows the user to enter data in the form. This element is used in the form element.

<select> tag

This element represents different options in the form of drop down list. One option is selected from this list of options.

<select required>
<option>Male
<option>Female
</select>
Try</>

<textarea> tag

textarea element defines multi line resizeable texte area. It supports required attribute.

<textarea value="Essay...." required> </textarea>
Try</>


Was this article helpful?

 

Email:

Message: