OTRS API Reference JavaScript

Namespace: Core.Form.Validate

Core.Form. Validate

This namespace contains all validation functions.
Author:
  • OTRS AG
Source:

Methods

(static) AddDependingValidation(Name, Basis, Depends)

This function adds special validation methods, which check a special rule only, if another depending method returns true.
Parameters:
Name Type Description
Name String The name of the rule aka the name of the class attribute used.
Basis String The rule which should be applied.
Depends function This function defines, if the given basis rule should be checked or not (parameter: the element which should be checked; returns true, if rule should be checked)
Source:

(static) AddMethod(Name, Function)

This function is used to add special validation methods. The name can be used to define new rules.
Parameters:
Name Type Description
Name String The name of the method.
Function function This function defines the specific validation method (parameter: value, element, params). Returns true if the element is valid.
Source:

(static) AddRule(Name, MethodHash)

This function is used to add special validation rules. The name is also the class name you can use in the HTML.
Parameters:
Name Type Description
Name String The name of the rule.
MethodHash Object This JS object defines, which methods should be included in this rule, e.g. { OTRS_Validate_Required: true, OTRS-Validate_MinLength: 2 }.
Source:

(static) DisableValidation($Form)

This function is used to disable all the elements of a Form object.
Parameters:
Name Type Description
$Form jQueryObject The form object that should be disabled.
Source:

(static) EnableValidation($Form)

This function is used to enable all the elements of a Form object.
Parameters:
Name Type Description
$Form jQueryObject The form object that should be enabled.
Source:

(static) HighlightError(Element, ErrorType) → {Boolean}

Shows an error on the element.
Parameters:
Name Type Description
Element DOMObject The DOM object of the form or any element.
ErrorType String The error type (a class that identifies the error type).
Source:
Returns:
False if error is already highlighted
Type
Boolean

(static) Init()

This function initializes the validation on all forms on the page which have a class named "Validate".
Source:

(static) SetSubmitFunction($Form, Func) → {Boolean}

This function defines the function which is executed when validation was successful on submitting the form.
Parameters:
Name Type Description
$Form jQueryObject The form, for which this submit function is used.
Func function The function, which is executed on successful submitting the form. Gets the submitted form as a parameter.
Source:
Returns:
Returns false, if $Form is not a jQueryObject.
Type
Boolean

(static) UnHighlightError(Element)

Remove error classes from element and its label.
Parameters:
Name Type Description
Element Object The object of the form or any element within this form.
Source:

(static) ValidateElement($Element) → {Boolean}

Validate a single element.
Parameters:
Name Type Description
$Element jQueryObject
Source:
Returns:
True, if element validates, false otherwise.
Type
Boolean