JavaScript has built-in functions that are automatically called when the mouse clicks on a link or even rolls over a links. See mouse.html for a demonstration.
The most important application of JavaScript is form validation. A form is an HTML element that contains user input controls such as text fields and buttons. Typically, a user fills in the text fields, then clicks the submit button. This sends the information in the text fields back to the server for processing. Online applications are an example of this.
The problem occurs when the user enters invalid data into the text fields. The burden is now on the server to detect these errors and send the form back to the user asking for corrections.
JavaScripts can be invoked when the user enters information in a field or clicks a submit button. These scripts can then validate the form before it is submitted to the server.
The next two examples show elaborate examples of combining forms with JavaScripts to produce applications that require no server intervention at all!
HTML forms are quite rudimentary. Web programmers are often
jealous of desk top application programmers because they can build rich user
interfaces containing complicated presentation logic such as auto completion, sliders,
progress meters, and zooming. In theory, it should be possible to use
JavaScript to build similar GUI components for Web Applications without
resorting to special plug-ins. In fact, this is the idea behind
Here's a form validation project: