Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
It’s pretty confusing to work out which attributes go with which input types when you’re meeting them all at once as we are here. But it’s actually quite straightforward when you start using them. For example, you can’t use min and max on a <textarea>, because that wouldn’t make sense, but you can use required.
Let’s look at a classic form example that most of us are already familiar with. Nearly all blogs have a comment section, with fields for the commenter’s name (required), her email address (required), URL (optional), and the comment (required). That would need a fair bit of JavaScript if we were to do our form validation by hand.
In HTML5, however, we need only use some new form types. We also add a submit button—currently browsers only show validation messages when a form is actually submitted.