Client-Side Validation with JavaScript
In this section, we briefly introduce the JavaScript scripting language as a client-side method for validation and other simple tasks. JavaScript isn't a fully fledged programming language like PHP: it can't connect to databases, it's limited as to which system resources it can interact with, and it can't do most tasks a web database application requires. However, JavaScript is good for interacting with a <form> and for controlling the display of data to the user.
|
Common uses of JavaScript in web database applications include:
-
Validation of <form> data, the main topic of this section.
-
Simple interaction with <form> data; e.g., JavaScript is often used to calculate values and display these in a data-entry widget.
-
Enhancing user interactions by adding dynamic elements to a web page. Common features include pull-down menus, mouseover changes to the presentation (rollovers ), and dialog boxes.
-
Customizing the browser and using information from the browser to enhance presentation.
Most of these techniques are oriented around events. An event is an action that occurs-such as a mouse passing over an object or a user clicking on a button-and that can be trapped through JavaScript code.
