Chapter 10. HTML Form Enhancements from Scratch
Introduction
Whether you’re trying to learn more about JavaScript and jQuery or you just want to code the most direct solution for your immediate problem, sometimes writing code from scratch is the best approach. This chapter aims to provide you with simple, generic solutions that will help you get started writing your own code.
It is important to note that while there are great benefits to starting from scratch, some of the more common problems you’ll encounter, such as remaining character count, autoresizing textareas, and form validation (just to name a few), have already been addressed by others. Please see Chapter 11 or visit the jQuery forums and blogs online for more information on how community-critiqued and community-tested plugins can help you. Sometimes it helps to look at someone else’s code to find out what you could do better with yours.
When necessary, I provide some sample HTML under the “Problem” heading of each recipe. This isn’t a philosophical statement—there isn’t anything wrong or problematic with naked HTML. I am, however, trying to reinforce the mind-set that JavaScript should be used for enhancing existing HTML and improving user interaction. JavaScript is, and should be considered, completely separate from your HTML.
Note
In the following recipes I am only showing XHTML code snippets relevant to the problem. Please make sure that your code is a complete XHTML document and that it passes validation. ...
Get jQuery Cookbook 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.