formcycle 8.1.3 - JavaScript for forms

Click here to view these help pages for a different version of formcycle.

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 heavy 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

formcycle uses and provides the library JQuery. Go to https://api.jquery.com/ to find the documentation of all its functions and objects.