Rule-based, cross-browser, client side HTML form validation library written in JavaScript
When you include the library in the DOM, it adds a Formation
object to the window. There are a number of useful
methods available on Formation
:
initForm()
- Allow consumers of Formation to initialize forms that may be added to the DOM after auto-initialization of the DOMsetDebug()
- when set to true
, will log messages, warnings, etc to the consolegetDebug()
- get the status of debugregisterRule()
- register a new rule to make it availablegetValidityChangedEventName()
- the defined event for when a form/element’s validation state changesSome useful DOM navigation methods (see ./src/utilities/dom-navigation.js
`):
findCurrentFormByTarget()
- Pass in any element and it will return the current Formation form
findRequiredFields()
- find all required fields for the supplied form
elementfindSubmitButton()
- find the submit
button for the supplied form
elementfindOptionalFields()
- find all optional fields for the supplied form
elementgetAllCheckboxesOrRadiosByName()
- find all input elements in the current form with the same name as the supplied element
getCheckboxOrRadioContainer()
- find all the DOM element which acts as a container for a set of input elements with the same name as element
getLinkedElement()
- find the element in the DOM linked to source
and return it