Validatious 2.0

Easy form validation with unobtrusive JavaScript

Timing validation

By default, Validatious will validate the form when the user clicks a submit button, or one of the forms action buttons. From there on fields will revalidate themselves in an instant fashion. You can disable this instant behaviour, or add it right from the start.

Example: default behaviour

Click submit, and then try to fill in name and tab to the next field to see this behaviour.

Example: no instant validation

Normally you choose one way to do validation and do it consistently. This way you simply alter the v2.Field.prototype.instant (default false) and v2.Field.prototype.instantWhenValidated (default true) properties. On this page, there are three forms with different settings, so the form must be retrieved through v2.Form.get (which ensures you always work on the same v2.Form instance for a given form element), the fields looped, and then have their configuration changed. A little complicated, but normally you'll avoid this.


Example: instant validation right from the start

Making fields instant right from the start requires the v2.Field.prototype.instant property to be set to true even before the validation is created. For this reason, the approach in the previous example cannot be used here since the validation will already have been applied. Instead we create the validation using the core API.


Next: Field visibility | Back to Core API features index

© 2008 Christian Johansen. Validatious is licensed with a BSD License, documentation and site content with CC Attribution-Share Alike. About.