summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorwei <>2006-09-02 00:29:04 +0000
committerwei <>2006-09-02 00:29:04 +0000
commit815c7462bbc4848939aa53cf375a0269d51b81fa (patch)
tree6fa4977ce42f8e28fa71fe32c1e9d07d43d01797 /framework
parent215c1294d356e35b7717b05892a45b9f0b76a847 (diff)
update validators
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/Javascripts/js/compressed/validator.js13
-rw-r--r--framework/Web/Javascripts/js/debug/validator.js25
-rw-r--r--framework/Web/Javascripts/prado/validation3.js25
3 files changed, 31 insertions, 32 deletions
diff --git a/framework/Web/Javascripts/js/compressed/validator.js b/framework/Web/Javascripts/js/compressed/validator.js
index d3d8c53e..c173014c 100644
--- a/framework/Web/Javascripts/js/compressed/validator.js
+++ b/framework/Web/Javascripts/js/compressed/validator.js
@@ -82,13 +82,14 @@ this.messages.show();this.visible=true;},formats:function(type)
{case"List":output+=messages[i]+"\n";break;case"BulletList":default:output+=" - "+messages[i]+"\n";break;case"SingleParagraph":output+=messages[i]+" ";break;}}
return output;}};Prado.WebUI.TBaseValidator=Class.create();Prado.WebUI.TBaseValidator.prototype={enabled:true,visible:false,isValid:true,options:{},_isObserving:{},group:null,manager:null,message:null,initialize:function(options)
{this.options=options;this.control=$(options.ControlToValidate);this.message=$(options.ID);this.group=options.ValidationGroup;this.manager=Prado.Validation.addValidator(options.FormID,this);},getErrorMessage:function()
-{return this.options.ErrorMessage;},updateControl:function()
-{if(this.message)
+{return this.options.ErrorMessage;},updateControl:function(focus)
+{this.refreshControlAndMessage();if(this.options.FocusOnError&&!this.isValid)
+Prado.Element.focus(this.options.FocusElementID);},refreshControlAndMessage:function()
+{this.visible=true;if(this.message)
{if(this.options.Display=="Dynamic")
this.isValid?this.message.hide():this.message.show();this.message.style.visibility=this.isValid?"hidden":"visible";}
if(this.control)
-this.updateControlCssClass(this.control,this.isValid);if(this.options.FocusOnError&&!this.isValid)
-Prado.Element.focus(this.options.FocusElementID);this.visible=true;},updateControlCssClass:function(control,valid)
+this.updateControlCssClass(this.control,this.isValid);},updateControlCssClass:function(control,valid)
{var CssClass=this.options.ControlCssClass;if(typeof(CssClass)=="string"&&CssClass.length>0)
{if(valid)
control.removeClassName(CssClass);else
@@ -99,12 +100,12 @@ this.options.OnValidate(this,invoker);if(this.enabled)
this.isValid=this.evaluateIsValid();else
this.isValid=true;if(this.isValid)
{if(typeof(this.options.OnSuccess)=="function")
-{this.visible=true;this.message.style.visibility="visible";this.updateControlCssClass(this.control,this.isValid);this.options.OnSuccess(this,invoker);}
+{this.refreshControlAndMessage();this.options.OnSuccess(this,invoker);}
else
this.updateControl();}
else
{if(typeof(this.options.OnError)=="function")
-{this.visible=true;this.message.style.visibility="visible";this.updateControlCssClass(this.control,this.isValid);this.options.OnError(this,invoker);}
+{this.refreshControlAndMessage();this.options.OnError(this,invoker);}
else
this.updateControl();}
this.observeChanges(this.control);return this.isValid;},observeChanges:function(control)
diff --git a/framework/Web/Javascripts/js/debug/validator.js b/framework/Web/Javascripts/js/debug/validator.js
index 7a963f82..d0293cbd 100644
--- a/framework/Web/Javascripts/js/debug/validator.js
+++ b/framework/Web/Javascripts/js/debug/validator.js
@@ -593,22 +593,25 @@ Prado.WebUI.TBaseValidator.prototype =
* element. Updating the validator control will set the validator
* <tt>visible</tt> property to true.
*/
- updateControl: function()
+ updateControl: function(focus)
{
+ this.refreshControlAndMessage();
+
+ if(this.options.FocusOnError && !this.isValid )
+ Prado.Element.focus(this.options.FocusElementID);
+ },
+
+ refreshControlAndMessage : function()
+ {
+ this.visible = true;
if(this.message)
{
if(this.options.Display == "Dynamic")
this.isValid ? this.message.hide() : this.message.show();
this.message.style.visibility = this.isValid ? "hidden" : "visible";
}
-
if(this.control)
this.updateControlCssClass(this.control, this.isValid);
-
- if(this.options.FocusOnError && !this.isValid)
- Prado.Element.focus(this.options.FocusElementID);
-
- this.visible = true;
},
/**
@@ -659,9 +662,7 @@ Prado.WebUI.TBaseValidator.prototype =
{
if(typeof(this.options.OnSuccess) == "function")
{
- this.visible = true;
- this.message.style.visibility = "visible";
- this.updateControlCssClass(this.control, this.isValid);
+ this.refreshControlAndMessage();
this.options.OnSuccess(this, invoker);
}
else
@@ -671,9 +672,7 @@ Prado.WebUI.TBaseValidator.prototype =
{
if(typeof(this.options.OnError) == "function")
{
- this.visible = true;
- this.message.style.visibility = "visible";
- this.updateControlCssClass(this.control, this.isValid);
+ this.refreshControlAndMessage();
this.options.OnError(this, invoker);
}
else
diff --git a/framework/Web/Javascripts/prado/validation3.js b/framework/Web/Javascripts/prado/validation3.js
index 6e9dfc0a..67d490e3 100644
--- a/framework/Web/Javascripts/prado/validation3.js
+++ b/framework/Web/Javascripts/prado/validation3.js
@@ -593,22 +593,25 @@ Prado.WebUI.TBaseValidator.prototype =
* element. Updating the validator control will set the validator
* <tt>visible</tt> property to true.
*/
- updateControl: function()
+ updateControl: function(focus)
{
+ this.refreshControlAndMessage();
+
+ if(this.options.FocusOnError && !this.isValid )
+ Prado.Element.focus(this.options.FocusElementID);
+ },
+
+ refreshControlAndMessage : function()
+ {
+ this.visible = true;
if(this.message)
{
if(this.options.Display == "Dynamic")
this.isValid ? this.message.hide() : this.message.show();
this.message.style.visibility = this.isValid ? "hidden" : "visible";
}
-
if(this.control)
this.updateControlCssClass(this.control, this.isValid);
-
- if(this.options.FocusOnError && !this.isValid)
- Prado.Element.focus(this.options.FocusElementID);
-
- this.visible = true;
},
/**
@@ -659,9 +662,7 @@ Prado.WebUI.TBaseValidator.prototype =
{
if(typeof(this.options.OnSuccess) == "function")
{
- this.visible = true;
- this.message.style.visibility = "visible";
- this.updateControlCssClass(this.control, this.isValid);
+ this.refreshControlAndMessage();
this.options.OnSuccess(this, invoker);
}
else
@@ -671,9 +672,7 @@ Prado.WebUI.TBaseValidator.prototype =
{
if(typeof(this.options.OnError) == "function")
{
- this.visible = true;
- this.message.style.visibility = "visible";
- this.updateControlCssClass(this.control, this.isValid);
+ this.refreshControlAndMessage();
this.options.OnError(this, invoker);
}
else