Custom Functions

_addEvent(string object, string event, string command, [boolean append])
The _addEvent function will dynamically attach the specified command to the requested event for the specified object.

The object argument should be a string containing the valid path to a form object that the event should be attached to.

The event argument is the name of the event to attach the command to. This is a required parameter.

The command argument is JavaScript code to attach to the event.

The append argument is an optional argument that accepts either the value true or false. If true, then the command will be attached to the end of any existing instructions already in the specified event. If false, then the event will be attached in front of any other instructions. The default value is true.

_addValidator(string name, object/string function, boolean alwaysRun)
The _addValidator function will dynamically initialize a new validation routine. When a new validator is created, two new methods are created: a validateXXXX() and an isXXXX() method (where XXXX is equal to the name argument.) The "validate" methods are used to initialize validation on the form. These type of methods return no value. The "is" methods will return true if no error occurred, or false if an error did occur.

The name argument is the base name of the new validation procedure. This is a required parameter.

The function argument is either a pointer to an existing function, or a string to which will be converted into the new method.

The alwaysRun argument is a boolean value. If set to true, the validation rule will always be run on the objects it's attached to—regardless if the field is required or contains a value. This is useful if you want to write "either/or" type validation rules. If set to false, then in order for the validation rule to run, there must either be a value in the field or it must be required. The default behavior is false.

_param(string value, string default, string type)
The _param function is used to check an argument to see if it's value meets certain criteria. It first checks to make sure the value was defined, if not, then the default value will be returned. If the value is defined, but doesn't match the specified type, then the default value will also be returned.

The value argument is required. This would normally be an item in the arguments[] array.

The default argument is optional. Use this to specify a default value to return. By default, an empty string is used for this argument.

The type argument is an optional argument specifying the data type of the value argument. By default, this is "string." Valid types are any string equal to a value which can be returned when using the "typeof" operator.

_removeSpaces(string value)
The _removeSpaces function remove all spaces from a string. This function is used throughout the API to remove spaces from lists of field names.
_setContainerValues(string object)
The _setContainerValues function will loop through all the fields in a qForm object and find all the select boxes, which are containers. When it finds match, it'll make sure each item in the select box is selected. This will ensure that the value received by the server matches that of the getValue() for the field. This function is automatically called right before the form is submitted to the server.

The object argument is required and should contain a valid qForm's object.

[< Back] [Index] [Next >]