FORMCYCLE 6.3.0 - JavaScript for forms

This page lists all additional JavaScript functions and methods that are available to FORMCYCLE forms. What follows is a short introduction of how to use these help pages and where you can find the different kinds of functions and objects.

All functions and objects described in these help pages are also available when you use the autocompletion feature of the JavaScript editor in the designer.

Where you can find FORMCYCLE-specific JavaScript functions and objects? There are the following possibilities, described in detail below:

global window scope

A few functions and objects are exposed directly in the global window scope. You can access them either by their directly, or by accessing the corresponding property of the window object. For example:

// Access the global object "XFC_METADATA", then it sub property "serverTime"
window.XFC_METADATA.serverTime;

// You can also access the "XFC_METADATA" directly
XFC_METADATA.serverTime;

These functions and objects are documented at formcycle/window.

xutil object

Polluting the global namespace is not a good idea, which is why most new functions are now added to the FORMCYCLE object jQuery.xutil. Access it with the prefix $.xutil:

// Retrieves the value of the URL parameter with the name "lang" (language)
$.xutil.getFormParam("lang");

These functions and objects are documented at formcycle/XUtil.

jQuery extensions

FORMCYCLE makes heavey use of the library JQuery. Once you have selected some HTML elements with this library, it offers a multitude of methods to work with these elements. It also allows others to add new methods.

FORMCYCLE offers many helpful utility methods that can be used with elements selected via JQuery:

// Select the input field named "tfID" via JQuery
const tfID = $("[name='tfID']");

// Add a custom validation to that input field
tfMail.errorFunc(() => this.value.length === 5 ? "" : "ID must have 5 characters.");

These methods are documented at formcycle/JQuery.

jQuery

The library JQuery is used and provided by FORMCYCLE. For the sake of completeness, you can also find its functions and objects documented in these help pages at jquery.