tmt.spry.widget.AccordionForm

This widget is based on Spry's accordion. It integrates it with the TMT Validator. Form fields are validated one panel at time. Each time the user leaves a panel and moves to a new one, the previous is validated. Whenever the form is submitted instead, all fields are validate in one single swap

In order to use this library you need tmt_core.js, tmt_form.js and tmt_validator.js, for form validation, tmt_spryaccordionform.js for the accordion and SpryAccordion.js from Spry's accordion

Samples

Syntax reference

The widget supports all the options supported by Spry's Accordion constructor options, plus an additional one:

callback Optional. Specify the name of a custom JavaScript function that will handle error notification. By default JavaScript alert boxes are used. You can also use the built-in tmt.validator.multiSectionBoxCallback (see sample).
If a custom call back is specified, the widget will pass the following arguments to it:
  1. formNode: a reference to the form DOM node
  2. hasErrors: true if the tab group contains validation errors, false otherwise
  3. tabResults: an array of objects, one for each tab, storing the following properties
    • label: the tab's label text
    • validators: an array of validator objects (containing name and message properties). If the tab doesn't contain any error, the array is empty

CSS classes

Whenever a panel contains form validation errors, the "tmtAccordionError" class is applied to its label.
Whenever a panel passes validation, the "tmtAccordionValid" class is applied to its label

API

validate() Validate all the panels inside the accordion and invoke the callback. Return true if the form doesn't contain errors, false otherwise (see sample)