Why use client-side validation (CSV)?With the explosion of thin-client development, most web applications do not utilize the resources of the client. It is almost viewed as 'taboo.' I contend that the client machine is a valuable resource that should be utilized for its processing capabilities. Most web applications use server-side processing to validate HTML forms. This works but is very inefficient since the request must be sent over the wire, checked, and a response sent back to the user. Why not let the client machine do the mundane field validation and let the server handle business logic validation? This framework is written to satisfy this request and validate HTML forms for field types where it should be, on the client-side. It is written entirely in Javascript and supports multiple browsers. A sample form is provided that utilizes this framework. Features of client-side validation (CSV):
A sample form is provided that utilizes this framework. Sample form with Client-side validation.Try it out!
Debug Select Element On Focus Use Message Box Allow Override Show Errors In Form Element Severity: Info Warn Critical |
|
Main validation function (csvValidate(args)) signature - /* * Validate a form's input fields. It will gather all input form elements and validate their fields. * If override is allowed, then it will compare new errors with old and if they are * the same and none of the errors are required, user can choose to still submit the form. * * frm - Form element id string * severity - severity of error ('warn', 'critical', 'info') * debug - boolean, if true, then alert statements will be produced. * displayWithMarker - if true, displays error message using marker; otherwise, * display where labels are * selectElement - if true, when person selects error link, it will focus and display * allowOverride - if true, user can override errors and submit the form * showErrorsInElement - if true, error message will be in input element * btnArary - button array you want disabled while processing */ function csvValidate(frm, severity, debug, displayWithMarker, selectElement, allowOverride, showErrorsInElement, aBtnArray) { |
Note: Character "r" before any of the below-mentioned notations makes the field mandatory. | ||
Field Type | Notation | Example Field ID |
---|---|---|
Number Field | int | int_DriverLicense |
String Field | alp | alp_FristName |
Alpha Numeric Field | aln | aln_Street |
Zip Code Field | zip | zip_PostalZone |
Date Field | dat | dat_DateOfBirth |
Email Field | eml | eml_EmailAddress |
SSN Field | ssn | ssn_SocialSecurityNumber |
Money Field | mny | mny_RegistrationFee |
Double Number Field | dbl | dbl_DoubleNumber |
Extra Information |
This software is licensed under the LGPL. See opensource.org for more information. Note, the source files are provided in a readable format. They are not in a compact form to minimize size and file load. When you include these files, your browser will cache them so the impact is only once. In addition, this non-compact form is more legible. If you prefer a compact form, then feel free to compact it. Client feedback using the following browsers:
|