From 846f6328a4b9b777da44b1b077a244a5a8d527ce Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 22 Jul 2006 01:58:33 +0000 Subject: add StringLength, multi-byte, check in TRangeValidator --- framework/Web/Javascripts/js/validator.js | 6 +++++- framework/Web/Javascripts/prado/validation3.js | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'framework/Web/Javascripts') diff --git a/framework/Web/Javascripts/js/validator.js b/framework/Web/Javascripts/js/validator.js index 959dd193..1480368f 100644 --- a/framework/Web/Javascripts/js/validator.js +++ b/framework/Web/Javascripts/js/validator.js @@ -174,7 +174,11 @@ return true;switch(this.options.Operator) return true;}});Prado.WebUI.TRangeValidator=Class.extend(Prado.WebUI.TBaseValidator,{evaluateIsValid:function() {var value=this.getValidationValue();if(value.length<=0) return true;if(typeof(this.options.DataType)=="undefined") -this.options.DataType="String";var min=this.convert(this.options.DataType,this.options.MinValue||null);var max=this.convert(this.options.DataType,this.options.MaxValue||null);value=this.convert(this.options.DataType,value);if(value==null) +this.options.DataType="String";if(this.options.DataType!="StringLength") +{var min=this.convert(this.options.DataType,this.options.MinValue||null);var max=this.convert(this.options.DataType,this.options.MaxValue||null);value=this.convert(this.options.DataType,value);} +else +{var min=this.options.MinValue||0;var max=this.options.MaxValue||Number.POSITIVE_INFINITY;value=value.length;} +if(value==null) return false;var valid=true;if(min!=null) valid=valid&&value>=min;if(max!=null) valid=valid&&value<=max;return valid;}});Prado.WebUI.TRegularExpressionValidator=Class.extend(Prado.WebUI.TBaseValidator,{evaluateIsValid:function() diff --git a/framework/Web/Javascripts/prado/validation3.js b/framework/Web/Javascripts/prado/validation3.js index 9ee7ed2f..0e765c48 100644 --- a/framework/Web/Javascripts/prado/validation3.js +++ b/framework/Web/Javascripts/prado/validation3.js @@ -1104,11 +1104,20 @@ Prado.WebUI.TRangeValidator = Class.extend(Prado.WebUI.TBaseValidator, return true; if(typeof(this.options.DataType) == "undefined") this.options.DataType = "String"; - - var min = this.convert(this.options.DataType, this.options.MinValue || null); - var max = this.convert(this.options.DataType, this.options.MaxValue || null); - value = this.convert(this.options.DataType, value); - + + if(this.options.DataType != "StringLength") + { + var min = this.convert(this.options.DataType, this.options.MinValue || null); + var max = this.convert(this.options.DataType, this.options.MaxValue || null); + value = this.convert(this.options.DataType, value); + } + else + { + var min = this.options.MinValue || 0; + var max = this.options.MaxValue || Number.POSITIVE_INFINITY; + value = value.length; + } + if(value == null) return false; -- cgit v1.2.3