`
Using required Attribute in HTML5
Here we will learn about required attribute in HTML5.
Introduction: The required attributes is
used with input field when input entry is required. When we use this attributes
with input type, then we can not keep it blank because browser will not allow
it. Now we use required attribute in form. We write the following code
<!DOCTYPE HTML>
<html>
<body>
<form method="post">
First Name <input type="text" name="fname" required="required" />
Last Name <input type="text" name="lname" /> </br>
<input type="submit" />
</form>
</body>
</html>
Then we run this code. The output will be as like below figure
If we keep fname input field blank and click on submit button then message
is displayed as like below figure