We do very little true data entry into our systems database. Most of what we do is updating the information already in, or adding an entry to the activity log for a server. I hadn’t really given much thought to form validation, until a coworker asked for it. Once again, there is already a jQuery plugin that does a fantastic job of this.
The jQuery Validation plugin works on many different levels. First, and most commonly, it will validate that you have entered values into required fields.
Beyond that, you can validate the data entered into the field is in the format you desire. Types include email, url, date (mm/dd/yyyy), ISO date (yyyy-mm-dd), number (float), digits (integer), credit card, US phone numbers, and equal to (retyping email address as an example).
You can also do min and max lengths, min and max values, as well as ranges. The best part is that you can force any of the format validation without making the field required entry.
For me, what makes this plugin hot with a capital HAW, is that you can do remote validation before the form is submitted. One of their demo pages is a mock signup form for Remember The Milk (type “Peter” in the username field). With this demo, the username field is set to remotely verify with an external source — in this mock-up it is just a static array in a PHP file — that the value you have entered doesn’t already exist. They are even nice enough to give you both the jQuery script and PHP code from the example.
I’m still in the process of adding the format validation to non-required fields in our system, but I’m already rawking the required validation, as well as the remote validation for unique values like host name and server name.