Author: michiel
Date: 2009-11-23 13:59:02 +0100 (Mon, 23 Nov 2009)
New Revision: 39844

Modified:
   mmbase/trunk/base-webapp/src/main/webapp/mmbase/validation/validation.js.jsp
Log:
fixed a bug with 0 and ''

Modified: 
mmbase/trunk/base-webapp/src/main/webapp/mmbase/validation/validation.js.jsp
===================================================================
--- 
mmbase/trunk/base-webapp/src/main/webapp/mmbase/validation/validation.js.jsp    
    2009-11-23 12:57:47 UTC (rev 39843)
+++ 
mmbase/trunk/base-webapp/src/main/webapp/mmbase/validation/validation.js.jsp    
    2009-11-23 12:59:02 UTC (rev 39844)
@@ -711,11 +711,11 @@
     }
 
     if (this.isRequired(el) && this.enforce(el, el.mm_isrequired_enforce)) {
-        if (value == "" || value == null) {
+        if (value === "" || value == null) { // === is essential because 0 == 
"" (0 converted to string evidentely is '' in javascript)
             return false;
         }
     } else {
-        if (value == "" || value == null) {
+        if (value === "" || value == null) {
             return true;
         }
     }
@@ -725,6 +725,7 @@
     if (! this.patternValid(el)) return false; // not perfect yet
     // @todo of course we can go a bit further here.
 
+
     // datetime validation is still broken. (those can have more fields and so 
on)
 
     // enumerations: but must of the time those would have given dropdowns and 
such, so it's hardly
@@ -909,7 +910,7 @@
         var entry = els[i];
         this.validateElement(entry, server);
     }
-    return this.invalidElements == 0;
+    return this.invalidElements === 0;
 }
 
 MMBaseValidator.prototype.removeValidation = function(el) {
@@ -982,7 +983,7 @@
         var valid = this.valid(entry);
         entry.prevValid = valid;
         this.elements.push(entry);
-        this.setClassName(this.valid(entry), entry);
+        this.setClassName(valid, entry);
         if (!valid) {
             this.invalidElements++;
         }
@@ -991,7 +992,7 @@
         }
 
     }
-    if (els.length == 0) {
+    if (els.length === 0) {
         if (this.validateHook) {
             this.validateHook(this.invalidElements == 0);
         }

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to