The main interface for interacting with the form validator. You can use it, for example, to listen to certain events during form validation.

Hierarchy

  • XmValidator

Index

Methods

Methods

_getVal

  • _getVal(item: JQuery, type: string): unknown
  • Finds the value of the given form element, irrespective of its type. The returned value depends on the form element's type.

    Parameters

    • item: JQuery

      Form element to process.

    • type: string

      The value of the given form element, usually its tag name or the type property of the input element.

    Returns unknown

on

  • on(event: "start" | "progress" | "end", eventCallback: function): void
  • Register a callback function for one of the events issued during form validation.

    The following events are available:

    • start: When form validation starts.
    • progress: When progress is made during form validation, ie. every time a single form field was validated. Form validation consists of validation a set of form element, possibly the entire form.
    • end: When form validation finishes.
    // Log a console message when the event is triggered
    xm_validator.on("start", function(data) { console.log('validate-start', data); });
    xm_validator.on("progress", function(data) { console.log('progress', data); });
    xm_validator.on("end", function(data) { console.log('validate-end', data) });

    Parameters

    • event: "start" | "progress" | "end"

      Name of the event to listen to.

    • eventCallback: function

      Callback that is called when the event occurs. The callback receives the index (idx) of the form element being validated, a list (items) of all items to be validated, the current item (item) that is being validated, and whether the current item is (valid).

        • (this: undefined, data: object): void
        • Parameters

          • this: undefined
          • data: object
            • idx: number
            • item: JQuery
            • items: JQuery
            • valid: boolean

          Returns void

    Returns void