PHP

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.

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 (i.e. closing browser's window, back to previous page, break out of frames, add to favorites/bookmark etc.) and using information from the browser to enhance presentation.

  • Displaying date, calendar, referring page and client's IP address, copy selected text, focus an html element or form element onload and many more.

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.

JavaScript is very easy to implement, all we need to do is put your code in the HTML document and tell the browser that it is JavaScript by specifying javascript tag. JavaScript allows us to create highly responsive interfaces that improve the user experience and provide dynamic functionality, without having to wait for the server to react and show another page. JavaScript also help fix browser problems or patch holes in browser support, for example fixing CSS layout issues in certain browsers.

by BrainBellupdated
Advertisement: