Validatious 2.0

Easy form validation with unobtrusive JavaScript

Field visibility

By default, Validatious will not validate fields that are not showing. This means that if the input/textarea/select element, or any of its parent elements, display style property is 'none', or visibility style property is 'hidden', then the field will not be validated.

If you want even hidden fields to be a part of the validation, you can change this behaviour through v2.Field.prototype.validateHidden:

// Default setting
v2.Field.prototype.validateHidden = false;

// Validate all hidden fields
v2.Field.prototype.validateHidden = true;

// Don't validate this field if it's not showing
var field = new v2.Field('name');
field.validateHidden = false;

Example

Try submitting the form and notice the error on the name field. Then click the link causing the name to be hidden (actually, it's parent elements is hidden), and submit the form again. No error should occur this time.

Show/hide name

Show/hide name

Next: Custom validators | 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.