Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501

Deprecated: Function create_function() is deprecated in /opt/lampp/htdocs/aiedam/aiesite/pmwiki.php on line 501
AIEDAM - ZAPSupport-Tutorials - FormValidation

Tutorials Support > Tutorials > FormValidation

ZAP recently overhauled it's conditionals processing and form validation capabilities in some powerful ways. Currently you can validate any form field for any input value (using expression matching), or using any standard pmwiki conditional. You can also do some simple checking for blank fields.

Required Fields
At the easiest level you can set the required field equal to a CSV list of field names. Each will be checked and a warning message will be given if any are left blank. Simple and straightforward, and easy to use.

Pattern Matching
Suppose you wanted to check an input value to see if it looked like a valid email, and give a warning message if it was not the proper format. You could use this snippet:

(:zapform:)
(:input text email:)
(:zap validate_email="^.+@.+\..+$ ? msg=Pass : warn=Fail":)
(:zap msg="":)
... rest of form ...

The first part of the parameter (before the ? ) give us the pattern used in the expression matching, the last two parameters (on either side of the : ) tell us to change field "msg" to the appropriate message based on whether it passes or fails. You can of course set any field to any value using the validate command.

Conditional Testing
Sometimes you don't want to test by matching to an expression, but by some other criteria. The "if" command allows you to do that. The syntax is similar to "validate" but takes a condition instead--usually involving ZAP's built in Field Replacement. Suppose for example you want to allow a new page to be created, but only if 1) the page does not already exist, and 2) the page is in the proper format. You also want ensure that it is only created in a certain group. The following snippet would do that:

(:zapform:)
(:input text newpage:)
(:zap fullnewpage="Group.{newpage}":)
(:zap if1="exists '{fullnewpage}' ? warn=Page already exists":)
(:zap if2="! pagefmt '{fullnewpage}' ? warn=Page invalid format":)
(:zap warn="":)
(:zap create="{fullnewpage}":)
... rest of form ...

In this code snippet, ZAP begins by pulling in the value submitted for field "newpage" to create "fullnewpage" and then checks two conditions (if1 & if2). If it fails either, processing stops, the warning is given, and the page is not created.

Because ZAP ties into PmWiki's conditional system, you can use any PmWiki conditional, and/or define your own custom conditionals in a config file for use in ZAP!

Note: ZAP even allows you to execute a CSV list of field=value commands when a conditions passes or fails. Just be sure to put a space around the , like the ? and : This enables you to avoid conflicts with commas in the field values.