ch.Validation
Description
Validation is an engine to validate HTML forms elements.
How-to
Parameters
-
el
- HTMLElement : A HTMLElement to create an instance of ch.Validation. -
options
- Object : Options to customize an instance.-
conditions
- Array : A collection of conditions to validate.-
name
- String : The name of the condition. -
message
- String : The given error message to the condition. -
fn
- String : The method to validate a given condition.
-
-
reference
- HTMLElement : It's a reference to position and size of element that will be considered to carry out the position. -
side
- String : The side option where the target element will be positioned. Default: "right". -
align
- String : The align options where the target element will be positioned. Default: "top". -
offsetX
- Number : Distance to displace the target horizontally. Default: 10. -
offsetY
- Number : Distance to displace the target vertically. Default: 0. -
position
- String : The type of positioning used. Default: "absolute".
-
Extends
Properties
.bubble
Bubble
Is the little sign that popover showing the validation message. It's a Popover component, so you can change it's content, width or height and change its visibility state.
.Component#name
String
The name of a component.
.conditions
Object
The collection of conditions.
.error
Object
The current error. If the validations has not error is "null".
.form
form
Reference to a Form instance. If there isn't any, the Validation instance will create one.
.trigger
HTMLElement
The validation trigger.
.uid
Number
A unique id to identify the instance of a component.
.Validation#name
String
The name of the component.
Methods
-
condition
- String : A given number of fold to disable. -
condition
- String : A given number of fold to enable.
.constructor()
Returns a reference to the constructor function.
.destroy()
Destroys an instance of Component and remove its data from asociated element.
.disable() → {component}
Disables an instance of Component.
.enable() → {component}
Enables an instance of Component.
.require() → {component}
Adds functionality or abilities from other classes.
.disable(condition) → {validation}
Disables an instance of a validation or a specific condition.
.enable(condition) → {validation}
Enables an instance of validation or a specific condition.
.refreshPosition() → {validation}
Sets or gets positioning configuration. Use it without arguments to get actual configuration. Pass an argument to define a new positioning configuration.
.clear() → {validation}
Clear active error.
.constructor()
Returns a reference to the constructor function.
.destroy()
Destroys a Validation instance.
.hasError() → {Boolean}
Checks if the validation has got errors but it doesn't show bubbles.
.isShown() → {Boolean}
Indicates if the validation is shown.
.message() → {validation|String}
Sets or gets messages to specifics conditions.
.validate() → {validation}
Validates the value of $el.
Events
'clear'
It emits an event when a validation is cleaned.
'destroy'
Emits when a component is destroyed.
'disable'
Emits when a component is disable.
'enable'
Emits when a component is enabled.
'error'
It emits an error event when a validation got an error.
'ready'
Event emitted when the component is ready to use.
'success'
It emits an event when a validation hasn't got an error.