Update of /var/cvs/html/mmbase/validation
In directory james.mmbase.org:/tmp/cvs-serv14766
Modified Files:
Tag: MMBase-1_8
validation.js.jsp
Log Message:
ported from head
See also: http://cvs.mmbase.org/viewcvs/html/mmbase/validation
Index: validation.js.jsp
===================================================================
RCS file: /var/cvs/html/mmbase/validation/validation.js.jsp,v
retrieving revision 1.11.2.30
retrieving revision 1.11.2.31
diff -u -b -r1.11.2.30 -r1.11.2.31
--- validation.js.jsp 3 Mar 2009 15:33:03 -0000 1.11.2.30
+++ validation.js.jsp 28 Apr 2009 16:34:37 -0000 1.11.2.31
@@ -9,7 +9,7 @@
* then call validator.setup(el).
*
* @author Michiel Meeuwissen
- * @version $Id: validation.js.jsp,v 1.11.2.30 2009/03/03 15:33:03 michiel Exp
$
+ * @version $Id: validation.js.jsp,v 1.11.2.31 2009/04/28 16:34:37 michiel Exp
$
*/
@@ -76,9 +76,10 @@
MMBaseValidator.prototype.onLoad = function(event) {
- if (this.root == null) {
+ if (this.root == null && event != null) {
this.root = event.target || event.srcElement;
}
+ //console.log("Root" + this.root);
this.addValidation(this.root);
//validatePage(target);
}
@@ -155,7 +156,6 @@
if (typeof(path) == "string") path = path.split(/\s+/);
var tagName = path.shift();
-
var tag = el == null ? null : el.firstChild;
while (tag != null) {
if (tag.nodeType == 1) {
@@ -327,6 +327,11 @@
el.mm_isbinary = this.hasJavaClass(el,
"org\.mmbase\.datatypes\.BinaryDataType");
return el.isbinary;
}
+MMBaseValidator.prototype.isCheckEquality = function(el) {
+ if (el.mm_ischeckequality != null) return el.mm_ischeckequality;
+ el.mm_ischeckequality = this.hasJavaClass(el,
"org\.mmbase\.datatypes\.CheckEqualityDataType");
+ return el.ischeckequality;
+}
MMBaseValidator.prototype.isXml = function(el) {
if (el.mm_isxml != null) return el.mm_isxml;
@@ -624,7 +629,6 @@
} else {
return el.value;
}
-
}
/**
@@ -638,7 +642,12 @@
this.log("Unsupported element " + el);
return true; // not yet supported
}
- if (this.isBinary(el)) return true; // not yet supported
+ if (this.isBinary(el)) {
+ return true; // not yet supported
+ }
+ if (this.isCheckEquality(el)) {
+ return true; // not yet supported
+ }
if (this.isRequired(el) && this.enforce(el, el.mm_isrequired_enforce)) {
if (value == "") {
@@ -671,8 +680,19 @@
MMBaseValidator.prototype.serverValidation = function(el) {
if (el == null) return;
try {
+ if (this.isBinary(el)) {
+ el.serverValidated = true;
+ return $("<result valid='true' class='implicit_binary' />")[0];
+ }
+ if (this.isCheckEquality(el)) { // Not yet supported
+ el.serverValidated = true;
+ return $("<result valid='true' class='implicit_checkequality'
/>")[0];
+ }
+
+
var key = this.getDataTypeKey(el);
var value = this.getDateValue(el);
+
var validationUrl = '<mm:url page="/mmbase/validation/valid.jspx" />';
this.getDataTypeArguments(key) +
(this.lang != null ? "&lang=" + this.lang : "") +
@@ -694,7 +714,8 @@
result = res.responseXML;
//console.log("" + res);
} else {
- result = $("<result valid='false' />");
+ el.serverValidated = true;
+ result = $("<result valid='false' />")[0];
}
}
});
@@ -710,7 +731,11 @@
*/
MMBaseValidator.prototype.validResult = function(xml) {
try {
- return "true" == "" + this.find(xml,
'result')[0].getAttribute("valid");
+ if (xml.documentElement) {
+ return "true" == xml.documentElement.getAttribute("valid");
+ } else {
+ return "true" == "" + $(xml).attr("valid");
+ }
} catch (ex) {
this.log(ex);
throw ex;
@@ -757,7 +782,7 @@
errorDiv.className = valid ? "mm_check_noerror" :
"mm_check_error";
if (errorDiv) {
$(errorDiv).empty();
- var errors = serverXml.documentElement.childNodes;
+ var errors = serverXml.documentElement ?
serverXml.documentElement.childNodes : [];
this.log("errors for " + element.id + " " + serverXml + "
" + errors.length);
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs