Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 3: Forms > Putting all this together

Putting all this together

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.

A blog comments form

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.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial