Sep 29
2008JavaScript For Validation can be (almost) painless
Filed Under (JavaScript, Web Design and Development) by admin on 29-09-2008
Any web developer who gathers information from actual human beings knows that there is always somebody who
- a) might be new to the whole Internet thing and doesn’t understand what they need to enter on web forms,
- b) likes entering weird stuff just because they can, or
- c) thinks they can exploit some kind of vulnerability on your web site by attempting to enter SQL or XSS injection code.
Obviously, the best and final defense (in my somewhat biased opinion) takes place on the back-end in your ASP, PHP, Java or .NET code.
However, the folks at JavaScript Coder and I believe that you can save a lot of time and trouble for about 90 percent of your end-users by helping them along with a little bit of front-end, client-side form validation.
Aside from jQuery (written by John Resig), the form validation script from JavaScript Coder is is probably the other JavaScript library I wish I had written myself. However, this script library does such a great job at validating form input, I simply keep re-using it from one project to the next.
They have excellent examples and documentation for this form validation script, and so I’ll restrain myself from repeating that. Let me just note that this script considers numerous real-world scenarios AND allows you to append your own custom validations (e.g., matching passwords).
In a nutshell, with this form validation script, you can check the following:
- required fields have a value (other than blank spaces)
- the maximum and minimum lengths of text input fields are enforced
- only specific types of characters are entered (alphabetic, numeric, alphanumeric, with & without spaces)
- the input matches your regular expression pattern
- at least one radio buttons is selected
- a specific OPTION from a SELECT element is not selected
- e-mail addresses are in the correct format
Considering the price of this JavaScript library ($0), this is an awesome bargain.





