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.

Note

The client-side scripting language we use here is best known as Java-Script. However, in June 1998, the European Computer Manufacturers Association (ECMA) agreed to be responsible for the standard implementations of the scripting language by Microsoft, Netscape, and Sun. Accordingly, the real name of the language is now ECMA-Script, based on the standard ECMA-262. The most recent version of ECMA-262 is the third edition, dated December 1999.

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 ...

Get Web Database Applications with PHP, and MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.