Finds the value of the given form element, irrespective of its type. The returned value depends on the form element's type.
Form element to process.
The value of the given form element, usually its tag
name or the type
property of the input element.
Finds all (potential) references of the given elements. The given elements themselves are not included in the returned result.
References are for example elements that have a hidden-if, read-only-if or required-if condition on one of the given elements.
Elements for which to find references.
Options for which elements to find. By default, finds all known references.
All references that were found.
Removes an event callback previously added via on.
Type of the event name for which to remove a listener.
Name of the event to for which to remove a listener.
Listener to remove.
Register a callback function for one of the events issued during form validation.
Uncaught errors in callbacks are caught, logged, and ignored otherwise.
The following events are available:
// Log a console message when the event is triggered
xm_validator.on("requestBegin", data => console.log("validate-request", data));
xm_validator.on("begin", data => console.log("validate-start", data));
xm_validator.on("progress", data => console.log("progress", data));
xm_validator.on("finish", data => console.log("validate-finish", data));
xm_validator.on("requestFinish", data => console.log("validate-finish", data));
Type of the event name for which to register a listener.
Name of the event to listen to.
Listener that is invoked when the event occurs.
When the form is submitted and a form field is not valid, the browser window is scrolled so that the invalid field becomes visible. By default, this scrolling is animated. This method can be used to disable the animation so that the scrolling is instantaneous.
Whether to animate the scrolling.
Updates the validation state (conditions such as hidden-if or read-only-if) for all given elements.
Base with elements to update.
When true
, elements are updated if when their state does not have changes (e.g. an element is
hidden even if already hidden).
The main interface for interacting with the form validator. You can use it, for example, to listen to certain events during form validation.