TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Using required Attribute in HTML5
A K
Sep 22, 2011
3.3
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
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
Using required Attribute in HTML5
Next Recommended Reading
How to use HTML5 Download Attribute