HTML required attribute

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

Example

<p>See in the url after submitting, input elements outside the form still belong to form due to 'form' attribute. </p>

 <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>
Try </>

required attribute values

required attribute is a boolean attribute.

Related Tags

input tags which support this attribute are as follows.

<input>

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

See the above given example.

<select> tag

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

Example

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

<textarea> tag

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

Example

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

Try</>


Was this article helpful?

 

Email:

Message:

Get the newsletter