FAQs

Validating fields

There are different ways to validate fields data in version 6

The Easy way

Use the validation settings inside the field settings area, then make sure you have a "Validate fields" action at the top of the form "submit" event with an "Event loader" in the fail event in order to reload the form when a validation rule fails.

The other way

Use a "Validate data" action and set the data provider to whatever data set you want to check, for example you can use the default request data set {data:}, then list the fields you want to validate in the data set along with the rule to be tested and the error message to be shown.

field1/required:this field is required
field1/email:it should have an email address

Custom validation function

1 - Custom JavaScript validation function

In the "Validation rules" box, write your custom validation function name followed by the error message to use: customfn:please enter a valid username.

Drag a JavaScript element into your section, and add the follwoing code:

jQuery.fn.form.settings.rules.customfn = function(value, param) {
  return false;
};
Your function should not return false all the time, you should use your own code to check the user value and return true or false.
You can pass an optional parameter to the validation function this way: customfn[param]:message
2 - Custom PHP validation function

Add a PHP action and write the code needed to do the validation you desire, then return some value, say "true" or "false" based on the codition success.

assuming the PHP action name is "php4", you will then need to have an "Event switcher" action with the data provider set to {var:php4}, set the "Event list" to true,false (which are the anticipated results of the data provider) and click "Update events", now you can add the actions you need to the new events which will be triggered based on the result of the PHP function.