More Form Validation
Requiring certain fields to have a value is a good starting point, but often applications demand more sophisticated validation capabilities. QForms rises to this challenge.
Out-of-the-Box Validation Methods
A variety of field validation methods come pre-built with qForms. To use these methods, simply reference the form and the form field name, and then call the method:
The following are just some of the validation methods qForms supports:
Each of these methods also has an
isXXX() version that returns a Boolean value and can be used in customized validation routines (described below).
Additional validation methods include the following:
createDependencyTo() The designated field is required only if the source field is selected/completed.
isNotNull()/isNotEmpty() Evaluate null and empty cases regardless of the field type (text, check/radio group, selection, and etc.).
n number of fields, requiring at least one of them to be selected/completed.
Custom Validation Routines
Beyond its stock validation routines, qForms offers a rather extensive capability to define custom validation routines. This extensibility centers around two key methods:
validateExp() evaluates the supplied Boolean expression to determine a field's validity, such as verifying that a particular field is equal to a certain value, or ensuring that a field contains a certain number of characters
_addValidator() facilitates the creation of a fully customizable JS function that serves as a new Validator (complete with
Time-Saving Form Validation