Required Attribute In HTML5

Required Attribute in HTML5

Forms allow for a new required attribute, which specifies, naturally, whether a particular input is required. Dependent upon your coding preference, you can declare this attribute in one of two ways:

  1. <input type="text" name="txtname" required>
  2. <input type="text" name="txtbod" required="required">

For Example :

<form method="post" action="">
 <label for="someInput">Your Name :</label>
 <input type="text" id="txtname" name="someInput" placeholder="Please Enter Name" required>
 <button type="submit">Submit</button>
</form>

If the input is left blank, and the form is submitted, the textbox will be highlighted.
Required Attribute In HTML5 Required Attribute In HTML5 Reviewed by Bhaumik Patel on 5:51 AM Rating: 5