|
VDaemon
PHP Library |
VDaemon
Extension | Table of Contents
VDaemon User Guide
Introduction
An important aspect of creating Web Forms pages for user input is to be able to check that
the information users enter is valid. VDaemon is a PHP library that grants an easy-to-use
but powerful way to check for errors and, if necessary, display messages to the user. VDaemon
provides several custom HTML tags (VDaemon tags) to allow developer define form validation
rules.
VDaemon provides a mechanism for all common types of validation - for example, testing
for valid dates or values within a specified range - plus ways to provide custom-written validation.
In addition, VDaemon allows for complete customization of how error information is displayed
to the user.
Using VDaemon tags
You enable validation of user input by adding VDaemon tags to your form as you would with
other HTML tags. Each VDaemon validation tag (validator) references an input tag on the
form. When the user's input is processed (for example, when the form is submitted), VDaemon
tests
the
user's input and sets a state to indicate whether the entry passed the validation test(s).
If any of the validation
tests fail, the entire form is set to invalid.
You can test the state of a form using your own (custom) code. For example, you can test
the state of a form for properly formatted and required information before updating a database
with the submitted information.
If you detect an invalid state, you bypass the database update. Typically, if any validation
check fails, user is returned to the form
page with error messages that you have predefined for VDaemon to display in the
event of validation failure. These
error messages will help to guide and prompt the user
to enter the required and/or properly formatted information.
Validating for Multiple Conditions
Each VDaemon validator performs just one test. However, you may wish to check
an input element for multiple conditions. For example, you might want to establish that a
field is required and that it is limited to accepting dates within a specific range. You
can have
more than
one validation tag reference a given input field in a form. In that case, the tests performed
by the validators are resolved using a logical AND. The data input by the user must
pass all the tests
in order to be considered valid.
In some instances, entries in several different formats might be valid. For example, if
you are prompting for a phone number, you might allow users to enter a local number, a long-distance
number, or an international number. This situation arises primarily when checking for specific
patterns of numbers or characters. To perform this type of test — a logical OR — you
use the group validator and specify multiple validators within it.
Displaying Error Information
Validators are not visible in the rendered form. However, if the validator detects
an error, it produces error message text that you specify. The error message can be displayed
in a variety of ways:
- In place
Each validator can be referenced by a VDaemon label. VDaemon label displays an error message
or glyph in place (usually next to the control where the error occurred).
- Summary
Validation errors can be collected and displayed in one place - for example, at the top of
the form. This strategy is often used in combination with displaying a glyph next to the input
fields with errors.
- In place and Summary
The error message can be different in the summary and in place. You can use this option to
show a shorter error message in place with more detail in the summary, or to show an error
glyph next to the input field and an error message in the summary.
Requirements
VDaemon requires:
- PHP version 4.2.0 or later
VDaemonSecure requires:
- PHP version 4.2.0 or later
- Zlib PHP extension
- Mcrypt PHP extension version 2.4.x or later
Contributions
This enhanced version of the VDaemon Manual would never come to existance, if the following
people would not help with their contribution to the project:
- Daniel Nelson, who made proof reading and added many useful comments
Support Information
Support can be obtained at:
http://www.x-code.com/vdaemon_web_form_validation.php
vdaemon@x-code.com
|