Update of /var/cvs/html/mmbase/validation
In directory james.mmbase.org:/tmp/cvs-serv8786

Modified Files:
        validation.js.jsp 
Added Files:
        numberInfo.jspx 
Log Message:
MMB-1700 (javascript part)


See also: http://cvs.mmbase.org/viewcvs/html/mmbase/validation
See also: http://www.mmbase.org/jira/browse/MMB-1700


numberInfo.jspx is new



Index: validation.js.jsp
===================================================================
RCS file: /var/cvs/html/mmbase/validation/validation.js.jsp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- validation.js.jsp   18 Apr 2008 08:54:28 -0000      1.52
+++ validation.js.jsp   12 Aug 2008 19:41:31 -0000      1.53
@@ -9,7 +9,7 @@
  *                              then call validator.setup(el).
  *
  * @author Michiel Meeuwissen
- * @version $Id: validation.js.jsp,v 1.52 2008/04/18 08:54:28 michiel Exp $
+ * @version $Id: validation.js.jsp,v 1.53 2008/08/12 19:41:31 michiel Exp $
  */
 
 
@@ -27,7 +27,7 @@
     this.validateHook;
     this.root = root;
     this.setup();
-    this.lang          = null;
+    this.lang          = "client";
     this.sessionName   = null;
     this.id = MMBaseValidator.validators.push(this);
     if (MMBaseValidator.validators.length == 1) {
@@ -322,7 +322,32 @@
 
 MMBaseValidator.prototype.INTEGER = /^[+-]?\d+$/;
 
-MMBaseValidator.prototype.FLOAT   = 
/^[+-]?(\d+|\d+\.\d*|\d*\.\d+)(e[+-]?\d+|)$/i;
+MMBaseValidator.prototype.getDecimalSeparator = function () {
+    if (this.DECIMAL == null) {
+       var url = '<mm:url page="/mmbase/validation/numberInfo.jspx" />';
+       var params = {lang: this.lang };
+       var result;
+       $.ajax({async: false, url: url, type: "GET", dataType: "xml", data: 
params,
+               complete: function(res, status){
+                   if (status == "success") {
+                       result = res.responseXML;
+                   } else {
+                       result = $("<numberInfo />");
+                   }
+               }
+              });
+       var decimal = this.find(result, 'numberInfo 
decimalSeparator')[0].childNodes[0].nodeValue;
+       this.DECIMAL = decimal  == "." ? "\\." : "[\\.\\" + decimal + "]";
+    }
+    return this.DECIMAL;
+}
+MMBaseValidator.prototype.floatRegExp = function() {
+    if (this.FLOAT == null) {
+       this.FLOAT = new RegExp("^[+-]?(\\d+|\\d+" + this.getDecimalSeparator() 
+ "\\d*|\\d*" + this.getDecimalSeparator() + "\\d+)(e[+-]?\\d+|)$");
+    }
+    return this.FLOAT;
+
+}
 
 MMBaseValidator.prototype.typeValid = function(el) {
     if (el.value == "") return true;
@@ -331,7 +356,7 @@
         if (! this.INTEGER.test(el.value)) return false;
     }
     if (this.isFloat(el)) {
-        if (! this.FLOAT.test(el.value)) return false;
+        if (! this.floatRegExp().test(el.value)) return false;
     }
     return true;
 
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to