Ticket #263 (new defect)

Opened 3 months ago

Last modified 3 months ago

Conditional validation of a forms control.

Reported by: karel Assigned to: mpo
Priority: minor Milestone: 0.4
Component: modules/kauri-forms Version: trunk
Keywords: Cc:

Description

Example use case: If you check the 'I want spam' checkbox, the 'email address' field becomes required.

Suggested solution: Add a 'condition' option to the "required" validator. This condition can be set to a function (which returns true when the value is required).

Change History

23/12/09 13:39:06 changed by karel

Actually, come to think of it, this 'condition' operator can be applied to all validators.

In the given example I can just disable the "email address" field if the checkbox is checked (Although this is not always an option).

Perhaps it would be nice if you could enable/disable specific validations? Example of how it would be used:

mySpamControl.valueChanged(function() {

if (this.getValue().valueOf() === true) {

myEmailControl.getValidator('required').enable(); myRequiredMarker.text("*");

} else {

myEmailControl.getValidator('required').disable(); myRequiredMarker.text("");

}

});

23/12/09 14:20:46 changed by karel

Bummer. Disabling the control doesn't disable validation. Changed this in rev 1430: Disabled controls are no longer validated.