Changing the error message
All aspects of the error message can be changed, including the content of the message, where it is placed, what type of tag it is, and what class it uses (even what class is attached to the field that had an error). Try out the next form to see how the various aspects are changed.
Notice from the example that multiple adjustments to the errors can be chained. Methods that modify a guard can all be chained together, much like jQuery methods.
The built in guards are not the only guards available. Custom
validation functions can be used in place of a built in guard by
passing a function instead of a string to the
method. The following form demonstrates custom guard validation.
Separate guards instances and defaults
Defaults for how guards.js behaves are available in
$.guards.defaults object. If you would like guards
to have default behavior that differs between two different forms,
one option is to create a separate
and change the defaults. The 2 forms below demonstrate this.
Errors in guards.js are displayed one at a time. The first guard to
detect an error is displayed before the next is considered. This
behavior can be changed by enabling stacked errors. To enabled
stacked errors, set
true. With stacked errors enabled, all errors will be displayed
rather than simply the first one. Below demonstrates two forms, one
with stacked errors, one without.