Web Application Architecture: Principles, Protocols and Practices by Shklar Leon & Rosen Rich

Web Application Architecture: Principles, Protocols and Practices by Shklar Leon & Rosen Rich

Author:Shklar, Leon & Rosen, Rich [Shklar, Leon]
Language: eng
Format: mobi
Publisher: John Wiley and Sons
Published: 2009-05-18T20:00:00+00:00


Figure 8.1 Example of client-side form validation using JavaScript. (

With this approach, the validation process is initiated with the submission of the form. As we mentioned previously, it is possible to perform validation on a per-field basis, using the onchange or onblur JavaScript event handlers in the <input> tags associated with individual form fields. (These handlers are invoked when a field’s value changes or when the focus of the browser moves away from that field.) The displaying of alert boxes as data is entered can become overwhelming and confusing to users. Depending on the application, the acceptability of entered field values may be dependent on other fields, in which case the “holistic” approach of validating on submission is preferable.

Naturally, validations that depend upon server-side calculations and comparisons still require communication with the server. This includes validations that require knowledge of stored authorization credentials and validations that require confirmation of user-supplied credit card information.

In practice, distinctions between the kinds of validation that can and cannot occur on the client are not so cut-and-dried. For example, even though confirmation of credit card information requires server-side information, it is possible to catch some errors (for example, credit card numbers that do not pass mod-10 checksum validation) on the client side. This preemptive validation weeds out simple typing errors before wasteful requests are sent to the server and, ultimately, to the credit-card validation service.

AJAX Validation



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.