Version 1.7 glow.forms.ValidateResult
API Quick Reference
JavaScript is required to use the quick reference
The overall result returned by an attempt to validate the current state of the form.
The ValidateResult object is used by glow.forms.Form to accumulate and record the test results as they are run. It is created automatically by the running validation so it is not necessary for the user to instantiate it directly, but it is useful to know the properties and their meanings as these will likely be referred to when a custom onValidate
handler is run.
Constructor
new glow.forms.ValidateResult(eventName)
-
Parameters
- eventName
-
- Type
Properties
- altKey
-
Whether the alt key was pressed during the key event.
- attachedTo
-
The object/element that the listener is attached to.
- button
-
A number representing which button was pressed.
- From
- glow.events.Event
- Type
Description
Only available for mouse events.
0 for the left button, 1 for the middle button or 2 for the right button.
- capsLock
-
Whether caps-lock was on during the key event
- From
- glow.events.Event
- Type
- | Undefined
Description
Only available for keyboard events.
If the key is not alphabetic, this property will be undefined as it is not possible to tell if caps-lock is on in this scenario.
- charCode
-
The unicode character code for a printable character.
- From
- glow.events.Event
- Type
- | Undefined
Description
Only available for keyboard events.
This will be undefined if the key was not a printable character.
- chr
-
A printable character string.
- From
- glow.events.Event
- Type
Description
Only available for keyboard events.
The string of the key that was pressed, for example 'j' or 's'.
This will be undefined if the key was not a printable character.
- ctrlKey
-
Whether the ctrl key was pressed during the key event.
- errorCount
-
The number of fields that had a failing test.
- Type
Description
From the
fields
property you can determine how many fields have failing or passing values; this is property is simply a more convenient way to access the total failing count of tests that fail. If no tests fail then this value will be 0 and you can consider the form to have validated. - eventName
-
The name of the event that was associated with this validation event.
- Type
Description
Validation can happen based on one of several different user interactions, this property allows you to identify the type of interaction that initiated this validation. Examples are:
- submit
- The user has done something to submit the form, for example by pressing the Submit button.
- change
- The user has modified the value of a form field.
- idle
- The user is typing in a form field but has paused for a moment (by default 1 second).
- click
- The user has clicked the mouse on or in a form field.
Which user interaction is associated with which tests is determined by the options you used when you added the test. See the documentation for glow.forms.Form#addTests for more information.
- fields
-
Each object in this array has a name of a field, a test result such as glow.forms.PASS, glow.forms.FAIL or glow.forms.SKIP, and a message describing the test result.
- Type
Description
The effect of validation is that the value or state of each field in the form is compared to the tests the developer has added to the fields. In each tested field a determination is made that the current value either passes or fails (or, if the test wasn't run at all, is skipped). The
fields
property provides information on the overall result of the validation, on each field that was tested and the results. - key
-
A short identifier for the key for special keys.
- From
- glow.events.Event
- Type
- | Undefined
Description
Only available for keyboard events.
If the key was not a special key this property will be undefined.
See the list of key identifiers in glow.events.addKeyListener
- keyCode
-
An integer number represention of the keyboard key that was pressed.
- pageX
-
The horizontal position of the mouse pointer in the page in pixels.
- pageY
-
The vertical position of the mouse pointer in the page in pixels.
-
The element that the mouse has come from or is going to.
- shiftKey
-
Whether the shift key was pressed during the key event.
- source
-
The actual object/element that the event originated from.
- From
- glow.events.Event
- Type
Description
For example, you could attach a listener to an 'ol' element to listen for clicks. If the user clicked on an 'li' the source property would be the 'li' element, and 'attachedTo' would be the 'ol'.
- wheelDelta
-
The number of clicks up (positive) or down (negative) that the user moved the wheel.
Methods
- defaultPrevented
-
Test if the default action has been prevented.
- From
- glow.events.Event
Synopsis
myValidateResult.defaultPrevented();
Returns
True if the default action has been prevented.
- preventDefault
-
Prevent the default action for events.
- From
- glow.events.Event
Synopsis
myValidateResult.preventDefault();
Description
This can also be achieved by returning false from an event callback
- propagationStopped
-
Tests if propagation has been stopped for this event.
- From
- glow.events.Event
Synopsis
myValidateResult.propagationStopped();
Returns
True if event propagation has been prevented.
- stopPropagation
-
Stops the event propagating.
- From
- glow.events.Event
Synopsis
myValidateResult.stopPropagation();
Description
For DOM events, this stops the event bubbling up through event listeners added to parent elements. The event object is marked as having had propagation stopped (see propagationStopped).
Example
// catch all click events that are not links glow.events.addListener( document, 'click', function () { alert('document clicked'); } ); glow.events.addListener( 'a', 'click', function (e) { e.stopPropagation(); } );