Fullscreen
[Show/Hide Right Column]

English British

Tracker Field Validation


jQuery AJAX validation

In Tiki6, jQuery AJAX validation was introduced. It works perfectly with fields that take text input but is not really suited or relevant to fields that have pre-configured selections, etc. (drop downs).

The Validation feature, under jQuery plugins and add-ons settings in the Features --> Interface panel has to be enabled for this to work.

When editing or adding a tracker field while configuring a tracker, you can choose a validation option. So far, the following validation procedures have been added:

distinct: Checks if the input text has been used before in the tracker for this field - thus ensuring all tracker items can be unique with respect to the validated field

username: Checks if username has been used already and is valid according to the rules configured in Tiki

password: Checks if the password is valid according to the rules configured in Tiki

regex: checks the entered text against any perl regular expression. Enter the regular expression as the "Validation parameter". (Do not include the starting and ending "/" enclosing the regular expression. These will be added automatically.)

Not all validation methods require a "Validation parameter" to be set.

Regardless of which validation method is selected, you can specify a default custom error message if desired, in "Validation error message:"

Adding new custom validation procedures

Developers can add new custom validation procedures in lib/validators. Each validator must be stored in a php file named "validator_nameofvalidator.php" and there must be a main function in the file with the general structure as follows:

function validator_nameofvalidator($input, $parameter = '', $message = '') {
...
...
...
if ($error) {
    return tra($message); // error message to be shown
}

return true; // successful validation


$parameter will be what is configured as the "Validation parameter:" in the tracker field settings, and $message is what is configured as the "Validation error message:" in the tracker field settings. You don't have to return $message as the error message if you don't want to (you can return any error message you want depending on the type of the error it is).


Contributors to this page: luciash d' being2153 points  , Marc Laporte8178 points  , Geoff Brickell742 points  and Nelson799 points  .
Page last modified on Friday 23 September, 2011 19:22:19 UTC by luciash d' being2153 points .
The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.

Site Language

Reference Guide

Keywords

These keywords serve as "hubs" for navigation within the Tiki documentation. They correspond to development keywords (bug reports and feature requests):



Tiki Newsletter

Delivered fresh to your email inbox!
Newsletter subscribe icon
Don't miss major announcements and other news!
Contribute to Tiki