Version 1.2 glow.forms.Form
API Quick Reference
JavaScript is required to use the quick reference
Create an object to add tests to.
Further Info & Examples
Constructor
new glow.forms.Form(formNode, opts)-
Parameters
- formNode
-
- Type
- glow.dom.NodeList | Selector
- opts
-
- Type
- Optional
- Yes
- onValidate
-
Handles the 'validate' event when all tests are complete.
- Type
- Optional
- Yes
Examples
myForm = new glow.forms.Form( glow.dom.get("#htmlFormId"), { onValidate: function(results) { // ... } } );
Properties
- formNode
-
- Type
- glow.dom.NodeList
- opts
-
- Type
Methods
- addTests
-
Add one or more tests to a field.
Synopsis
myForm.addTests(fieldName, spec);Parameters
- fieldName
-
- Type
The name of the field to add tests to.
- spec
-
- Type
- Optional
- Yes
Test specifications identify the type of test to be run on a field to determine whether it contains desired data. See docs on the types of tests.
Example
//pattern for a test specification [ "testName", //name of the test to run { arg : 5, //an argument for the test, not all tests need this on : "submit change", //when should this test be run? message : "Incorrect value" //a custom error message to display } ]//setting a form up for validation var myForm = new glow.forms.Form(glow.dom.get("#myFormId")) .addTests( "username", ["required"], ["maxLen", {arg: 12, message: "Name must be les than 12 characters long."}] ) .addTests( "email", ["isEmail"] ); - validate
-
Run validation tests.
Synopsis
myForm.validate(eventName, fieldName);Parameters
- eventName
-
- Type
- Default
- 'submit'
- Optional
- Yes
Run only tests tied to this eventname.
- fieldName
-
- Type
- Optional
- Yes
Run only tests attached to the form element with this name.