Ticket #263 (closed defect: fixed)

Opened 8 months ago

Last modified 12 days ago

Conditional validation of a forms control.

Reported by: karel Owned by: freya
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).

Attachments

Change History

Changed 8 months ago 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("");

}

});

Changed 8 months ago by karel

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

Changed 3 months ago by mpo

  • milestone changed from 0.4 to 0.4.1

Changed 5 weeks ago by freya

  • owner changed from mpo to freya
  • status changed from new to assigned

Changed 4 weeks ago by freya

(In [1648]) * See #263 : conditional validator. you can add a 'isEnabled' method to a validator to sepcify whether or not to enable the validation.

Changed 4 weeks ago by freya

'+validators': {

'isEmail': {

'isEnabled': function(){

// check some other fields and return a boolean to enable/disable return true;

}

}, 'required': {}

}

Changed 4 weeks ago by freya

  • status changed from assigned to closed
  • resolution set to fixed

Changed 12 days ago by jgou

  • milestone changed from 0.4.1 to 0.4

Add/Change #263 (Conditional validation of a forms control.)

Author


E-mail address and user name can be saved in the Preferences.


Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.