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.