´óÏó´«Ã½

Please turn on JavaScript. To find out how to do this visit the .

Create an object to add tests to.

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. Default is glow.forms.feedback.defaultFeedback.

Type
Optional
Yes

Examples

myForm = new glow.forms.Form(
  glow.dom.get("#htmlFormId"),
  {
    onValidate: function(results) {
      // ...
    }
  }
);

Properties

formNode

NodeList containing the form element

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.

Description

This is called automatically depending on the tests added to the form. However, you can trigger validation manually

Documentation generated by 2.1.0 on Mon Jul 20 2009 14:55:30 GMT+0100 (BST)

´óÏó´«Ã½ iD

´óÏó´«Ã½ navigation

´óÏó´«Ã½ © 2014 The ´óÏó´«Ã½ is not responsible for the content of external sites. Read more.

This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.