Chapter 5

Creating Forms

Forms are an integral part of most apps and websites. In recent years, forms have progressed to a point in HTML5 where you can provide very rich functionality without any JavaScript at all. Of course, not all browsers support these advanced features, so you'll often need to provide JavaScript fallbacks. Fortunately, a lot of third-party polyfills are available that you can use to back up HTML5 form features automatically.

In this chapter, you learn how to use a progressive enhancement approach in your forms. You start with a solid-base state that works across all browsers, and then you add JavaScript features on top. You then discover a variety of HTML5 form features, such as special input types, widgets, and validation. Next, you learn how to use polyfills to support these features in older, non-supportive browsers. You also read about some techniques for posting your forms via Ajax. Finally, you find out how to connect your forms with Backbone, automatically generating the view and posting the form data with Backbone's syncing.

Understanding Progressive Enhancement

This chapter's general approach is one of progressive enhancement, which is widely accepted as the best practice for handling forms with JavaScript (and pretty much everything else you might augment with JS). This approach starts with a more limited foundation that works across all browsers, and then progressively enhances that base state with additional features wherever they can be supported. ...

Get JavaScript Programming: Pushing the Limits now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.