The motivating factor behind the creation of Web Applications 1.0, the original proposal that evolved to become HTML5, was to extend the power of HTML forms to allow the creation of rich and flexible online applications. HTML5 doesn’t disappoint, bringing a whole new range of elements, attributes, and controls to make forms richer, more interactive, and more informative in the modern web platform.
Many JavaScript frameworks, such as the popular jQuery UI, provide controls and widgets that extend the functionality of form elements; these range from simple enhancements such as automatically suggesting values as you type to more complex user interface elements such as those that allow you to pick a date. Given HTML5’s stated aim of standardizing common design patterns, it comes as no surprise that these common form elements should become part of the specification.
Other than new widgets and form interactions, the most common use of JavaScript in forms is to check for errors while the user is filling out the form, and to ensure the data is correctly formatted and doesn’t contain any nasty surprises before being sent to the server. HTML5 also provides a native implementation of this validation, with a series of new attributes and input types that require set patterns of data, including on-screen notes and alerts in many browsers, and an API that gives developers more flexibility when using script.