From f920798fd13d0d76b12da1f2862e52cf7bbff6e1 Mon Sep 17 00:00:00 2001 From: Jens Klaer Date: Tue, 15 Sep 2015 11:32:34 +0200 Subject: small fixes for clientside validation --- .../source/prado/validator/validation3.js | 44 ++++++++++++---------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'framework') diff --git a/framework/Web/Javascripts/source/prado/validator/validation3.js b/framework/Web/Javascripts/source/prado/validator/validation3.js index bdf0f592..24466599 100644 --- a/framework/Web/Javascripts/source/prado/validator/validation3.js +++ b/framework/Web/Javascripts/source/prado/validator/validation3.js @@ -439,9 +439,9 @@ Prado.ValidationManager.prototype = */ isValid : function(group) { - for(var i = 0; i < this.validatorPartition(group)[0]; i++) + for(var i = 0; i < this.validatorPartition(group)[0].length; i++) { - if(!this.validatorPartition(group)[0].isValid()) + if(!this.validatorPartition(group)[0][i].isValid) return false; } @@ -456,16 +456,16 @@ Prado.ValidationManager.prototype = addValidator : function(validator) { // Remove previously registered validator with same ID - // to prevent stale validators created by AJAX updates - this.removeValidator(validator); + // to prevent stale validators created by AJAX updates + this.removeValidator(validator); this.validators.push(validator); if(validator.group && jQuery.inArray(validator.group, this.groups)==-1) this.groups.push(validator.group); - if (typeof this.controls[validator.control.id] === 'undefined') - this.controls[validator.control.id] = Array(); - this.controls[validator.control.id].push(validator); + if(typeof this.controls[validator.control.id] === 'undefined') + this.controls[validator.control.id] = Array(); + this.controls[validator.control.id].push(validator); }, /** @@ -483,19 +483,25 @@ Prado.ValidationManager.prototype = * @function ? * @param {TBaseValidator} validator - Validator object */ - removeValidator : function(validator) + removeValidator : function(validator) + { + // Remove from list of validators + this.validators = jQuery.grep(this.validators, function(v) + { + return (v.options.ID!=validator.options.ID); + }); + // Remove from global list of validators per control + if (this.controls[validator.control.id]) { - this.validators = jQuery.grep(this.validators, function(v) - { - return (v.options.ID!=validator.options.ID); - }); - // WTF? - if (this.controls[validator.control.id]) - jQuery.grep(this.controls[validator.control.id], function(v) - { - return (v.options.ID!=validator.options.ID) - }); - }, + this.controls[validator.control.id] = jQuery.grep(this.controls[validator.control.id], function(v) + { + return (v.options.ID!=validator.options.ID) + }); + // Delete array if empty + if(this.controls[validator.control.id].length == 0) + delete this.controls[validator.control.id]; + } + }, /** * Gets validators with errors. -- cgit v1.2.3