Javascript Validation


I am always on the lookout for new ways to improve the websites I create and one of the best ways I have found to improve user input is to use Javascript to validate the data before sending it to the server. I recently came across not one, but two Javascript validation scripts that can help improve client-side form validation.

The first is LiveValidation. It validates the form input as you type and gives feedback right beside the form field. The script can also work with or without the prototype.js library. They also offer an uncommented version of the script that weighs in only at 14kb, 12kb lighter than the commented version.

The second is JSValidate. In the examples it validates when the form is submitted or the form field looses focus, presenting the user with a cool fade-in feedback beside the form field very similar to LiveValidation. The script does not require any other external libraries and they offer two types of downloads. The full download is 25kb and the squished version is 14kb.

Both scripts look promising to be able to provide users with valuable feedback when they are filling out a form. They are also not to bad as far as size goes and you could probably get those sizes down even more if you use some GZIP Compression to compress the files when the browser requests them. I will have to give them a try on my next web project that I need to do some form validation on.

Always remember that you still need to have server side validation of data as well. Javascript validation is really only a tool to help improve a users experience of a website to guide them to enter the proper information. The people and robots we want to prevent from entering our forms will do their best to avoid javascript validation.

Do you have any experience with either of these scripts? It would be great to know what your thoughts are on them by leaving a comment.

Categories: web-programming