On this page I give the code you need for checking user input in a form.
Using these bits of code, you can write your own scripts to validate forms I can't give you a complete script, because each form and each check are different.
For example, in a Web site like where users are entering shipping and billing information, it is vital that the user enter credit card numbers, zip codes, email addresses, and other information in an acceptable format.
For example, imagine that you had a questionnaire that asked the user a number of questions in radiobutton and checkbox form.
Imagine that you had a series of checkboxes that corresponded to the hobbies sports, reading, and swimming, and you asked the ready to check all hobbies that he enjoyed.
See also Jeff Howden's excellent article Forms & Java Script Living Together in Harmony for some of the most common usability errors and their solutions.
First of all, you should have a clear idea of what happens when a user submits a form that has a Java Script validation script: : by the Java Script and by the CGI script.
The advantage for the user is that it's obvious whick element is causing the problem and there's no alert window that needs to be clicked away.