Client Side Or Server Side Validation?
As some of you know, I am quite the proponent of client-side validation for Web applications and Web sites. The main reasons are speed and load.
A Web application that expects a pile of use could better be served if its pages are smart enough to capture common problems without sending a server request and making your poor, creaking Web server figure out what’s wrong. Basic stuff that client-side logic, generally through JavaScript, can determine includes making sure the user enters required data, enters information in accepted patterns for the expected data (zip codes, e-mail addresses, and so on) and date validation. That way, when your Web server is hammered by a blog linking to your site, you can rest assured your confusing interface will not necessarily bring down your site.
On the other hand, there’s the speed issue. When users click Submit and send off that form data to your Web site, they’ll have to wait again for your wizbang media-rich page to load again or worse, wait for two pages to load if you use separates page for the error message and the form. So what, your cool Web designers and infrastructure people say. Well, friends, I personally have used dial-up AOL in the not too distant past, and I know how slow normal pages are to load. Even if you’re not dealing with customers on dial-up AOL at 33k, according to these numbers, 17% of users don’t have broadband. Granted, your tech team and designers are perfectly willing to sacrifice the impatient amongst those slowpokes, but your clients or business users probably wouldn’t like to hear that 10,000 of your 100,000 visitors are abandoning forms because they’re slow and frustrating.
So there are two compelling reasons to use the client-side validation, and they’re small potatoes compared to the developers’ counter-arguments (”It’s too hard” or “It’s too expensive” or “If the user has JavaScript disabled, it won’t work!”). Good reasons versus poor practices, and you’ll be lucky if you win using logic.
Now, as a best practice, your organization should actually use both client-side and server-side data validation for the optimal data protection. This will handle any flaws or browser incompatibility in your client-side data validation.
What would a QAHatesYou.com post be without pointing out how a Web form has not handled it very well? Ask, and ye shall receive!
Newegg.com ran a Guitar Hero III sweepstakes that didn’t follow these best practices.
For example, client side validation is in place for the Birthday field:

Click for full size

Click for full size

Click for full size
So to make a short story long and to give you a set of bullet points you can cut and paste into your best practices document:
- Always include client side validation on Web forms/applications to make them faster for users and to remove common data problems from the server load.
- Use client-side validation to ensure that user has entered information in all required fields.
- Use client-side validation to ensure that user-entered data matches known patterns for valid data, including Zip codes, dates, and other structured bits of data.
- Check to make sure user has changed any default instructional text prepopulated in controls.
- Make sure that validation messages are grammatically correct and spelled correctly.
- Make sure validation works consistently among browsers.
The Web will be a better place for it.