/**//*
* JavaScript Validation Framework
*
* Author: Michael Chen(mechiland) on 2004/03
* This software is on the http://www.cosoft.org.cn/projects/jsvalidation
* for update, bugfix, etc, you can goto the homepage and submit your request
* and question.
* Apache License 2.0
* You should use this software under the terms.
*
* Please, please keep above words. At least ,please make a note that such as
* "This software developed by Michael Chen(http://www.jzchen.net)" .
* $Id: validation-framework.js,v 1.7 2004/04/30 05:33:29 jzchen Exp $
* update :
1) 2007-12-16 add support of firefox 2. // by lein
Main changes:
a. In ValidationFramework.getDocumentElement, a little difference of 'xmlDoc' between firefox and ie was incarnated.
b. In FormFactory.getFormFromId, firefox doesn't support has item property of xmldoc.
*/
/**//** Config Section, Config these fields to make this framework work. **/
// If there is only one config file in your system, use this property. otherwise, use
// ValidationFramework.init("configfile")
// instead.
//alert(window.location.href)
var ValidationRoot = "";
// the field style when validation fails. it aim to provide more beautiful UI and more good
// experience to the end-user.
// NOTE: this will be buggy. Please report the error to me.
// The style has been changed at 2007-12-10;
var ValidationFailCssStyle = "border:1px solid #F77B00; color:#D90005";
//Validation function. The entry point of the framework.
function doValidate(formRef) ...{
try ...{
var formId = formRef;
if (typeof (formRef) == "string") ...{
formId = formRef;
} else if (typeof (formRef) == "object") ...{
formId = formRef.getAttribute("id");
}
//alert(formId)
var form = FormFactory.getFormFromId(formId);
if (form != null) ...{
//alert(form)
return ValidationFramework.validateForm(form);
} else ...{
return false;
}
} catch (e) ...{
ValidationFramework.exception(e.name+":" +e.description);
return false;
}
}
/**//**===================================================================**/
/**//* var prefix = ["MSXML2", "MSXML", "Microsoft", "MSXML3"];
for (var i = 0; i < prefix.length; i++) {
//return new ActiveXObject(prefix[i] + ".DomDocument");
var obj = new ActiveXObject(prefix[i] + ".DomDocument");
* JSValidation Framework Code Started
*
* Please do not modify the code unless you are very familiar with JavaScript.
* The best way to solve problem is report the problem to our project page.
* url: http://cosoft.org.cn/projects/jsvalidation
*/
// The Xml document. To process cross-browser. Thanks Eric.
function XmlDocument() ...{
}
XmlDocument.create = function () ...{
//alert("XmlDocument.create ")
return Try.these(
function()...{return new ActiveXObject('MSXML2.DomDocument')},
function()...{return new ActiveXObject('MSXML.DomDocument')},
function()...{return new ActiveXObject('Microsoft.DomDocument')},
function()...{return new ActiveXObject('MSXML3.DomDocument')}
) || false;
};
function ValidationFramework() ...{}
ValidationFramework._validationCache = null;
ValidationFramework._currentForm = null;
ValidationFramework._userLanguage="auto";
/**//**
* Validate a form.
* NOTE: the form is Framework virture form, not the HTML Form.
* Html Form can be transform to Virture form by
* FormFactory.getFormFromId(htmlFormId);
* See the doc for more information.
* @param form the virtual form.
*/
ValidationFramework.validateForm = function(fform) ...{
ValidationFramework._currentForm = fform;
var failFields = [];
var id = fform.getId();
var showError = fform.getShowError();
var showType = fform.getShowType();
//alert(id+"|"+showError+"|"+showType+"110")
var br = null;
if (showError != "alert") ...{
br = "<br />";
} else ...{
br = " ";
}
var errorStrArray = [];
var ret = false;
var formObj = document.getElementById(id);
////alert("formObj.tagName is "+formObj.getTagName())
formObj=document.getElementById(FormToChk);
//alert("ok")
var fields = fform.getFields();
//alert("fields.length="+fields.length)
var rightnum = 0;
for (var i = 0; i < fields.length; i++) ...{
//alert(fields[i])
var retVal = ValidationFramework.validateField(fields[i]);
var fo=formObj[fields[i].getName()];
//alert(fo+"|fields[i].getName()="+fields[i].getName())
if (typeof (fo) !='undefined' &&
fo != null &&
typeof(fo.type) != "undefined") ...{
fo.style.cssText = "";
}
if (retVal != "OK") ...{
errorStrArray[errorStrArray.length] = retVal;
failFields[failFields.length] = formObj[fields[i].getName()];
} else ...{
rightnum ++;
}
}
if (rightnum == fields.length) ...{
ret = true;
}
if (errorStrArray.length > 0) ...{
* JavaScript Validation Framework
*
* Author: Michael Chen(mechiland) on 2004/03
* This software is on the http://www.cosoft.org.cn/projects/jsvalidation
* for update, bugfix, etc, you can goto the homepage and submit your request
* and question.
* Apache License 2.0
* You should use this software under the terms.
*
* Please, please keep above words. At least ,please make a note that such as
* "This software developed by Michael Chen(http://www.jzchen.net)" .
* $Id: validation-framework.js,v 1.7 2004/04/30 05:33:29 jzchen Exp $
* update :
1) 2007-12-16 add support of firefox 2. // by lein
Main changes:
a. In ValidationFramework.getDocumentElement, a little difference of 'xmlDoc' between firefox and ie was incarnated.
b. In FormFactory.getFormFromId, firefox doesn't support has item property of xmldoc.
*/
/**//** Config Section, Config these fields to make this framework work. **/
// If there is only one config file in your system, use this property. otherwise, use
// ValidationFramework.init("configfile")
// instead.
//alert(window.location.href)
var ValidationRoot = "";
// the field style when validation fails. it aim to provide more beautiful UI and more good
// experience to the end-user.
// NOTE: this will be buggy. Please report the error to me.
// The style has been changed at 2007-12-10;
var ValidationFailCssStyle = "border:1px solid #F77B00; color:#D90005";
//Validation function. The entry point of the framework.
function doValidate(formRef) ...{
try ...{
var formId = formRef;
if (typeof (formRef) == "string") ...{
formId = formRef;
} else if (typeof (formRef) == "object") ...{
formId = formRef.getAttribute("id");
}
//alert(formId)
var form = FormFactory.getFormFromId(formId);
if (form != null) ...{
//alert(form)
return ValidationFramework.validateForm(form);
} else ...{
return false;
}
} catch (e) ...{
ValidationFramework.exception(e.name+":" +e.description);
return false;
}
}
/**//**===================================================================**/
/**//* var prefix = ["MSXML2", "MSXML", "Microsoft", "MSXML3"];
for (var i = 0; i < prefix.length; i++) {
//return new ActiveXObject(prefix[i] + ".DomDocument");
var obj = new ActiveXObject(prefix[i] + ".DomDocument");
* JSValidation Framework Code Started
*
* Please do not modify the code unless you are very familiar with JavaScript.
* The best way to solve problem is report the problem to our project page.
* url: http://cosoft.org.cn/projects/jsvalidation
*/
// The Xml document. To process cross-browser. Thanks Eric.
function XmlDocument() ...{
}
XmlDocument.create = function () ...{
//alert("XmlDocument.create ")
return Try.these(
function()...{return new ActiveXObject('MSXML2.DomDocument')},
function()...{return new ActiveXObject('MSXML.DomDocument')},
function()...{return new ActiveXObject('Microsoft.DomDocument')},
function()...{return new ActiveXObject('MSXML3.DomDocument')}
) || false;
};
function ValidationFramework() ...{}
ValidationFramework._validationCache = null;
ValidationFramework._currentForm = null;
ValidationFramework._userLanguage="auto";
/**//**
* Validate a form.
* NOTE: the form is Framework virture form, not the HTML Form.
* Html Form can be transform to Virture form by
* FormFactory.getFormFromId(htmlFormId);
* See the doc for more information.
* @param form the virtual form.
*/
ValidationFramework.validateForm = function(fform) ...{
ValidationFramework._currentForm = fform;
var failFields = [];
var id = fform.getId();
var showError = fform.getShowError();
var showType = fform.getShowType();
//alert(id+"|"+showError+"|"+showType+"110")
var br = null;
if (showError != "alert") ...{
br = "<br />";
} else ...{
br = " ";
}
var errorStrArray = [];
var ret = false;
var formObj = document.getElementById(id);
////alert("formObj.tagName is "+formObj.getTagName())
formObj=document.getElementById(FormToChk);
//alert("ok")
var fields = fform.getFields();
//alert("fields.length="+fields.length)
var rightnum = 0;
for (var i = 0; i < fields.length; i++) ...{
//alert(fields[i])
var retVal = ValidationFramework.validateField(fields[i]);
var fo=formObj[fields[i].getName()];
//alert(fo+"|fields[i].getName()="+fields[i].getName())
if (typeof (fo) !='undefined' &&
fo != null &&
typeof(fo.type) != "undefined") ...{
fo.style.cssText = "";
}
if (retVal != "OK") ...{
errorStrArray[errorStrArray.length] = retVal;
failFields[failFields.length] = formObj[fields[i].getName()];
} else ...{
rightnum ++;
}
}
if (rightnum == fields.length) ...{
ret = true;
}
if (errorStrArray.length > 0) ...{