2010-06-15 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Mon, 14 Jun 2010 23:25:07 +0000 (23:25 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Mon, 14 Jun 2010 23:25:07 +0000 (23:25 -0000)
* WebUIValidation_2.0.js: fail gracefully if control to validate
is not found (webForm.ValidatorGetValue and
webForm.Page_ClientValidate). Fixes bug #609478

svn path=/trunk/mcs/; revision=158905

mcs/class/System.Web/resources/ChangeLog
mcs/class/System.Web/resources/WebUIValidation_2.0.js

index 6b63e159d16e7930bff972b4fb93466af57e605f..47140c8f5bcbd591756b9350d12215a5412353a7 100644 (file)
@@ -1,3 +1,9 @@
+2010-06-15  Marek Habersack  <mhabersack@novell.com>
+
+       * WebUIValidation_2.0.js: fail gracefully if control to validate
+       is not found (webForm.ValidatorGetValue and
+       webForm.Page_ClientValidate). Fixes bug #609478
+
 2009-10-05  Marek Habersack  <mhabersack@novell.com>
 
        * WebUIValidation_2.0.js: before using webFrom.Page_Validators,
index 5f23ef204e27ed4ccb3924e901b73487b6eef11b..926390ca27bb89d0243c803508c8f8a20122c541 100644 (file)
@@ -159,6 +159,8 @@ webForm.ValidatorCommonOnSubmit = function ()
 webForm.ValidatorGetValue = function (controlname)
 {
        var el = webForm.GetElement (controlname);
+        if (el == null)
+               return null;
 
        /* if the element has a 'value' attribute, return it */
        if (typeof (el.value) != 'undefined' && el.value != null) {
@@ -188,6 +190,9 @@ webForm.ValidatorGetValueRecursive = function (el)
 
 webForm.ValidatorTrim = function (s)
 {
+        if (s == null)
+              return null;
+
        s = s.replace (/^\s+/g, "");
        s = s.replace (/\s+$/g, "");
 
@@ -213,12 +218,15 @@ webForm.Page_ClientValidate = function (group)
                        var vo = webForm.Page_Validators [v];
                        var evalfunc = vo.evaluationfunction;
                        var result = false;
+                       var el = webForm.GetElement (vo.controltovalidate);
 
-                       if (!vo._enabled || !webForm.IsValidationGroupMatch(vo, group)) {
+                       if (el == null) {
+                               result = true;
+                               webForm.ValidatorSucceeded (vo);
+                       } else if (!vo._enabled || !webForm.IsValidationGroupMatch(vo, group)) {
                                result = true;
                                webForm.ValidatorSucceeded (vo);
-                       }
-                       else {
+                       } else {
                                result = evalfunc.call (this, vo);
                        }
 
@@ -499,7 +507,7 @@ webForm.RequiredFieldValidatorEvaluateIsValid = function (validator)
        var ControlToValidate = validator.controltovalidate;
 
        var ctrl_value = webForm.ValidatorTrim (webForm.ValidatorGetValue (ControlToValidate));
-
+        
        if (ctrl_value == webForm.ValidatorTrim (InitialValue)) {
                webForm.ValidatorFailed (validator);
                return false;