Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Incorrect removal of error messages in client-side validation (bug #1…

…9063)

git-svn-id: http://svn.php.net/repository/pear/packages/HTML_QuickForm2/trunk@323419 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit 0fa4de2c79ef613357b29641ea94d1a41365c41f 1 parent 59f0b1d
@sad-spirit sad-spirit authored
View
16 data/js/min/quickform-hierselect.js
@@ -3,13 +3,13 @@
Package version @package_version@
http://pear.php.net/package/HTML_QuickForm2
- Copyright 2006-2011, Alexey Borzov, Bertrand Mansion
- Licensed under new BSD license
+ Copyright 2006-2012, Alexey Borzov, Bertrand Mansion
+ Licensed under new BSD license
http://opensource.org/licenses/bsd-license.php
*/
-qf.elements.hierselect=function(){function g(b){return function(){setTimeout(function(){if(b.id in qf.elements.hierselect.defaults)for(var c=qf.elements.hierselect.defaults[b.id],d=b.hierselect.next,a=0;a<d.length;a++)qf.elements.hierselect.replaceOptions(document.getElementById(d[a]),qf.elements.hierselect.getOptions(b.id,c.slice(0,a+1))),qf.form.setValue(d[a],c[a+1])},1)}}function h(b){return function(){if(b.id in qf.elements.hierselect.defaults){var c=qf.elements.hierselect.defaults[b.id],d=b.hierselect.next;
-qf.form.setValue(b,c[0]);for(var a=0;a<d.length;a++)qf.form.setValue(d[a],c[a+1])}}}function i(b){b=qf.events.fixEvent(b);b.target.hierselect&&0!=b.target.hierselect.next.length&&qf.elements.hierselect.cascade.call(b.target)}return{init:function(b,c){for(var d=[],a=document.getElementById(b[0]),e;b.length&&(e=b.shift());){d.push(e);var f=document.getElementById(e);f.hierselect={previous:d.concat(),next:b.concat(),callback:c};qf.events.addListener(f,"change",i)}qf.events.addListener(a.form,"reset",
-g(a));qf.events.addListener(window,"load",h(a))},getValue:function(b){for(var c=[],d=0;d<b.length;d++)c.push(qf.form.getValue(b[d]));return c},replaceOptions:function(b,c){function d(b){var a=document.createElement("div");a.innerHTML=b;return a.childNodes[0]?a.childNodes[0].nodeValue:""}for(var a=b.options.length=0;a<c.values.length;a++)b.options[a]=new Option(-1==String(c.texts[a]).indexOf("&")?c.texts[a]:d(c.texts[a]),c.values[a],!1,!1)},getOptions:function(b,c,d){if(!(b in qf.elements.hierselect.options)||
-typeof qf.elements.hierselect.options[b][c.length-1]=="undefined")return qf.elements.hierselect.missingOptions;for(var a=qf.elements.hierselect.options[b][c.length-1],e=c.concat();e.length;){var f=e.shift();if(0==e.length)return f in a||(a[f]=d?d(c,b):qf.elements.hierselect.missingOptions),a[f];else f in a||(a[f]={});a=a[f]}},getAsyncCallback:function(b,c){return function(d){b in qf.elements.hierselect.options||(qf.elements.hierselect.options[b]=[]);typeof qf.elements.hierselect.options[b][c.length-
-1]=="undefined"&&(qf.elements.hierselect.options[b][c.length-1]={});for(var a=qf.elements.hierselect.options[b][c.length-1],e=c.concat();e.length;){var f=e.shift();0==e.length?a[f]=d:a=f in a?a[f]:a[f]={}}a=document.getElementById(b).hierselect;e=document.getElementById(a.next[c.length-1]);qf.elements.hierselect.replaceOptions(e,d);c.length<a.next.length&&qf.elements.hierselect.cascade.call(e)}},cascade:function(){var b=qf.elements.hierselect.getValue(this.hierselect.previous);qf.elements.hierselect.replaceOptions(document.getElementById(this.hierselect.next[0]),
-qf.elements.hierselect.getOptions(this.hierselect.previous[0],b,this.hierselect.callback));1<this.hierselect.next.length&&qf.elements.hierselect.cascade.call(document.getElementById(this.hierselect.next[0]))},missingOptions:{values:[""],texts:[" "]},options:{},defaults:{}}}();
+qf.elements.hierselect=function(){function i(a){return function(){setTimeout(function(){if(a.id in qf.elements.hierselect.defaults)for(var c=qf.elements.hierselect.defaults[a.id],d=a.hierselect.next,b=0;b<d.length;b++)qf.elements.hierselect.replaceOptions(document.getElementById(d[b]),qf.elements.hierselect.getOptions(a.id,c.slice(0,b+1))),qf.form.setValue(d[b],c[b+1])},1)}}function j(a){return function(){if(a.id in qf.elements.hierselect.defaults){var c=qf.elements.hierselect.defaults[a.id],d=a.hierselect.next;
+qf.form.setValue(a,c[0]);for(var b=0;b<d.length;b++)qf.form.setValue(d[b],c[b+1])}}}function k(a){a=qf.events.fixEvent(a);a.target.hierselect&&0!=a.target.hierselect.next.length&&qf.elements.hierselect.cascade.call(a.target)}return{init:function(a,c){for(var d=[],b=document.getElementById(a[0]),e;a.length&&(e=a.shift());){d.push(e);var f=document.getElementById(e);f.hierselect={previous:d.concat(),next:a.concat(),callback:c};qf.events.addListener(f,"change",k)}qf.events.addListener(b.form,"reset",
+i(b));qf.events.addListener(window,"load",j(b))},getValue:function(a){for(var c=[],d=0;d<a.length;d++)c.push(qf.form.getValue(a[d]));return c},replaceOptions:function(a,c){for(var d=a.options.length=0;d<c.values.length;d++){var b=a.options,e=d,f=Option,g;if(-1==(""+c.texts[d]).indexOf("&"))g=c.texts[d];else{g=c.texts[d];var h=document.createElement("div");h.innerHTML=g;g=h.childNodes[0]?h.childNodes[0].nodeValue:""}b[e]=new f(g,c.values[d],!1,!1)}},getOptions:function(a,c,d){if(!(a in qf.elements.hierselect.options)||
+"undefined"==typeof qf.elements.hierselect.options[a][c.length-1])return qf.elements.hierselect.missingOptions;for(var b=qf.elements.hierselect.options[a][c.length-1],e=c.concat();e.length;){var f=e.shift();if(0==e.length)return f in b||(b[f]=d?d(c,a):qf.elements.hierselect.missingOptions),b[f];f in b||(b[f]={});b=b[f]}},getAsyncCallback:function(a,c){return function(d){a in qf.elements.hierselect.options||(qf.elements.hierselect.options[a]=[]);"undefined"==typeof qf.elements.hierselect.options[a][c.length-
+1]&&(qf.elements.hierselect.options[a][c.length-1]={});for(var b=qf.elements.hierselect.options[a][c.length-1],e=c.concat();e.length;){var f=e.shift();0==e.length?b[f]=d:b=f in b?b[f]:b[f]={}}b=document.getElementById(a).hierselect;e=document.getElementById(b.next[c.length-1]);qf.elements.hierselect.replaceOptions(e,d);c.length<b.next.length&&qf.elements.hierselect.cascade.call(e)}},cascade:function(){var a=qf.elements.hierselect.getValue(this.hierselect.previous);qf.elements.hierselect.replaceOptions(document.getElementById(this.hierselect.next[0]),
+qf.elements.hierselect.getOptions(this.hierselect.previous[0],a,this.hierselect.callback));1<this.hierselect.next.length&&qf.elements.hierselect.cascade.call(document.getElementById(this.hierselect.next[0]))},missingOptions:{values:[""],texts:[" "]},options:{},defaults:{}}}();
View
39 data/js/min/quickform.js
@@ -3,28 +3,27 @@
Package version @package_version@
http://pear.php.net/package/HTML_QuickForm2
- Copyright 2006-2011, Alexey Borzov, Bertrand Mansion
- Licensed under new BSD license
+ Copyright 2006-2012, Alexey Borzov, Bertrand Mansion
+ Licensed under new BSD license
http://opensource.org/licenses/bsd-license.php
*/
var qf=qf||{};qf.elements=qf.elements||{};
-qf.typeOf=function(a){var b=typeof a;if("function"==b&&"undefined"==typeof a.call)return"object";else if("object"==b)if(a){if(a instanceof Array||!(a instanceof Object)&&"[object Array]"==Object.prototype.toString.call(a)&&"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if(!(a instanceof Object)&&("[object Function]"==Object.prototype.toString.call(a)||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&
+qf.typeOf=function(a){var b=typeof a;if("function"==b&&"undefined"==typeof a.call)return"object";if("object"==b)if(a){if(a instanceof Array||!(a instanceof Object)&&"[object Array]"==Object.prototype.toString.call(a)&&"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if(!(a instanceof Object)&&("[object Function]"==Object.prototype.toString.call(a)||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&
!a.propertyIsEnumerable("call")))return"function"}else return"null";return b};qf.addNamespace=function(a){for(var a=a.split("."),b=window,c;a.length&&(c=a.shift());)b=b[c]?b[c]:b[c]={}};qf.Map=function(a){this._map={};this._keys=[];this._count=0;a&&this.merge(a)};
-qf.Map.prototype=function(){function a(a,d){return Object.prototype.hasOwnProperty.call(a,d)}function b(){if(this._count!=this._keys.length){for(var b=0,d=0,e={};b<this._keys.length;){var g=this._keys[b];a(this._map,g)&&!a(e,g)&&(this._keys[d++]=g,e[g]=!0);b++}this._keys.length=d}}return{hasKey:function(b){return a(this._map,b)},length:function(){return this._count},getValues:function(){b.call(this);for(var a=[],d=0;d<this._keys.length;d++)a.push(this._map[this._keys[d]]);return a},getKeys:function(){b.call(this);
-return this._keys.concat()},isEmpty:function(){return 0==this._count},clear:function(){this._map={};this._count=this._keys.length=0},remove:function(c){if(!a(this._map,c))return!1;delete this._map[c];this._count--;this._keys.length>this._count*2&&b.call(this);return!0},get:function(b,d){if(a(this._map,b))return this._map[b];return d},set:function(b,d){a(this._map,b)||(this._count++,this._keys.push(b));this._map[b]=d},merge:function(a,b){var e,g,f=0;if(a instanceof qf.Map)e=a.getKeys(),g=a.getValues();
-else for(var h in e=[],g=[],a)e[f]=h,g[f++]=a[h];h=b||qf.Map.mergeReplace;for(f=0;f<e.length;f++)this.hasKey(e[f])?this.set(e[f],h(this.get(e[f]),g[f])):this.set(e[f],g[f])}}}();qf.Map.mergeReplace=function(a,b){return b};qf.Map.mergeKeep=function(a){return a};qf.Map.mergeArrayConcat=function(a,b){"array"!=qf.typeOf(a)&&(a=[a]);"array"!=qf.typeOf(b)&&(b=[b]);return a.concat(b)};qf.form=function(){return{getValue:function(a){typeof a=="string"&&(a=document.getElementById(a));if(!a||!("type"in a))return null;switch(a.type.toLowerCase()){case "checkbox":case "radio":return a.checked?a.value:null;case "select-one":var b=a.selectedIndex;return-1==b?null:a.options[b].value;case "select-multiple":for(var b=[],c=0;c<a.options.length;c++)a.options[c].selected&&b.push(a.options[c].value);return b;default:return typeof a.value=="undefined"?null:a.value}},getSubmitValue:function(a){typeof a==
-"string"&&(a=document.getElementById(a));if(!a||!1 in a||a.disabled)return null;switch(a.type.toLowerCase()){case "reset":case "button":return null;default:return qf.form.getValue(a)}},getContainerSubmitValue:function(){for(var a=new qf.Map,b=0;b<arguments.length;b++)if(arguments[b]instanceof qf.Map)a.merge(arguments[b],qf.Map.mergeArrayConcat);else{if("object"==qf.typeOf(arguments[b]))var c=arguments[b].name,d=arguments[b].value;else c=document.getElementById(arguments[b]).name,d=qf.form.getSubmitValue(arguments[b]);
-if(null!==d){var e={};e[c]=d;a.merge(e,qf.Map.mergeArrayConcat)}}return a},setValue:function(a,b){typeof a=="string"&&(a=document.getElementById(a));if(a&&"type"in a)switch(a.type.toLowerCase()){case "checkbox":case "radio":a.checked=!!b;break;case "select-one":var c=a;c.selectedIndex=-1;for(var d,e=0;d=c.options[e];e++)if(d.value==b){d.selected=!0;break}break;case "select-multiple":c=a;d=b;"array"!=qf.typeOf(d)&&(d=[d]);for(var g=0;e=c.options[g];g++){e.selected=!1;for(var f=0,h=d.length;f<h;f++)if(e.value==
-d[f])e.selected=!0}break;default:a.value=b}}}}();qf.$v=qf.form.getSubmitValue;qf.$cv=qf.form.getContainerSubmitValue;qf.classes={add:function(a,b){"string"==qf.typeOf(b)&&(b=b.split(/\\s+/));if(a.className){for(var c=" "+a.className+" ",d=a.className,e=0,g=b.length;e<g;e++)b[e]&&0>c.indexOf(" "+b[e]+" ")&&(d+=" "+b[e]);a.className=d}else a.className=b.join(" ")},remove:function(a,b){if(a.className){"string"==qf.typeOf(b)&&(b=b.split(/\\s+/));for(var c=(" "+a.className+" ").replace(/[\n\t\r]/g," "),d=0,e=b.length;d<e;d++)b[d]&&(c=c.replace(" "+b[d]+" "," "));a.className=c.replace(/^\s+/,"").replace(/\s+$/,"")}},
-has:function(a,b){if(-1<(" "+a.className+" ").replace(/[\n\t\r]/g," ").indexOf(" "+b+" "))return!0;return!1}};qf.events={test:function(){var a={submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1},b=document.createElement("div");if(b.attachEvent)for(var c in{submit:!0,change:!0,focusin:!0}){var d="on"+c,e=d in b;e||(b.setAttribute(d,"return;"),e=typeof b[d]==="function");a[c+"Bubbles"]=e}return a}(),addListener:function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d):a.attachEvent("on"+b,c)},removeListener:function(a,b,c,d){a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent("on"+b,c)},
-fixEvent:function(a){a=a||window.event;a.preventDefault=a.preventDefault||function(){this.returnValue=!1};a.stopPropagation=a.stopPropagation||function(){this.cancelBubble=!0};if(!a.target)a.target=a.srcElement;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement==a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){var b=document.documentElement,c=document.body;a.pageX=a.clientX+(b&&b.scrollLeft||c&&c.scrollLeft||0)-(b.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
-c&&c.scrollTop||0)-(b.clientTop||0)}if(!a.which&&a.button)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a}};qf.Rule=function(a,b,c,d){this.callback=a;this.owner=b;this.message=c;this.chained=d||[[]]};qf.LiveRule=function(a,b,c,d,e){qf.Rule.call(this,a,b,c,e);this.triggers=d};qf.LiveRule.prototype=new qf.Rule;qf.LiveRule.prototype.constructor=qf.LiveRule;
-qf.Validator=function(a,b){this.rules=b||[];this.errors=new qf.Map;a.validator=this;qf.events.addListener(a,"submit",qf.Validator.submitHandler);for(var c=0,d;d=this.rules[c];c++)if(d instanceof qf.LiveRule){qf.events.test.changeBubbles?qf.events.addListener(a,"change",qf.Validator.liveHandler,!0):(qf.events.addListener(a,"click",function(a){var a=qf.events.fixEvent(a),b=a.target;("select"==b.nodeName.toLowerCase()||"input"==b.nodeName.toLowerCase()&&("checkbox"==b.type||"radio"==b.type))&&qf.Validator.liveHandler(a)}),
-qf.events.addListener(a,"keydown",function(a){var a=qf.events.fixEvent(a),b=a.target,d="type"in b?b.type:"";(13==a.keyCode&&"textarea"!=b.nodeName.toLowerCase()||32==a.keyCode&&("checkbox"==d||"radio"==d)||"select-multiple"==d)&&qf.Validator.liveHandler(a)}));qf.events.test.focusinBubbles?qf.events.addListener(a,"focusout",qf.Validator.liveHandler,!0):qf.events.addListener(a,"blur",qf.Validator.liveHandler,!0);break}};
+qf.Map.prototype=function(){function a(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function b(){if(this._count!=this._keys.length){for(var c=0,b=0,e={};c<this._keys.length;){var f=this._keys[c];a(this._map,f)&&!a(e,f)&&(this._keys[b++]=f,e[f]=!0);c++}this._keys.length=b}}return{hasKey:function(c){return a(this._map,c)},length:function(){return this._count},getValues:function(){b.call(this);for(var a=[],d=0;d<this._keys.length;d++)a.push(this._map[this._keys[d]]);return a},getKeys:function(){b.call(this);
+return this._keys.concat()},isEmpty:function(){return 0==this._count},clear:function(){this._map={};this._count=this._keys.length=0},remove:function(c){if(!a(this._map,c))return!1;delete this._map[c];this._count--;this._keys.length>2*this._count&&b.call(this);return!0},get:function(c,b){return a(this._map,c)?this._map[c]:b},set:function(c,b){a(this._map,c)||(this._count++,this._keys.push(c));this._map[c]=b},merge:function(a,b){var e,f,g=0;if(a instanceof qf.Map)e=a.getKeys(),f=a.getValues();else{e=
+[];f=[];for(var h in a)e[g]=h,f[g++]=a[h]}h=b||qf.Map.mergeReplace;for(g=0;g<e.length;g++)this.hasKey(e[g])?this.set(e[g],h(this.get(e[g]),f[g])):this.set(e[g],f[g])}}}();qf.Map.mergeReplace=function(a,b){return b};qf.Map.mergeKeep=function(a){return a};qf.Map.mergeArrayConcat=function(a,b){"array"!=qf.typeOf(a)&&(a=[a]);"array"!=qf.typeOf(b)&&(b=[b]);return a.concat(b)};qf.form=function(){return{getValue:function(a){"string"==typeof a&&(a=document.getElementById(a));if(!a||!("type"in a))return null;switch(a.type.toLowerCase()){case "checkbox":case "radio":return a.checked?a.value:null;case "select-one":var b=a.selectedIndex;return-1==b?null:a.options[b].value;case "select-multiple":for(var b=[],c=0;c<a.options.length;c++)a.options[c].selected&&b.push(a.options[c].value);return b;default:return"undefined"==typeof a.value?null:a.value}},getSubmitValue:function(a){"string"==
+typeof a&&(a=document.getElementById(a));if(!a||!1 in a||a.disabled)return null;switch(a.type.toLowerCase()){case "reset":case "button":return null;default:return qf.form.getValue(a)}},getContainerSubmitValue:function(){for(var a,b,c=new qf.Map,d=0;d<arguments.length;d++)if(arguments[d]instanceof qf.Map)c.merge(arguments[d],qf.Map.mergeArrayConcat);else if("object"==qf.typeOf(arguments[d])?(a=arguments[d].name,b=arguments[d].value):(a=document.getElementById(arguments[d]).name,b=qf.form.getSubmitValue(arguments[d])),
+null!==b){var e={};e[a]=b;c.merge(e,qf.Map.mergeArrayConcat)}return c},setValue:function(a,b){"string"==typeof a&&(a=document.getElementById(a));if(a&&"type"in a)switch(a.type.toLowerCase()){case "checkbox":case "radio":a.checked=!!b;break;case "select-one":var c=a;c.selectedIndex=-1;for(var d,e=0;d=c.options[e];e++)if(d.value==b){d.selected=!0;break}break;case "select-multiple":c=a;d=b;"array"!=qf.typeOf(d)&&(d=[d]);for(var f=0;e=c.options[f];f++){e.selected=!1;for(var g=0,h=d.length;g<h;g++)e.value==
+d[g]&&(e.selected=!0)}break;default:a.value=b}}}}();qf.$v=qf.form.getSubmitValue;qf.$cv=qf.form.getContainerSubmitValue;qf.classes={add:function(a,b){"string"==qf.typeOf(b)&&(b=b.split(/\\s+/));if(a.className){for(var c=" "+a.className+" ",d=a.className,e=0,f=b.length;e<f;e++)b[e]&&0>c.indexOf(" "+b[e]+" ")&&(d+=" "+b[e]);a.className=d}else a.className=b.join(" ")},remove:function(a,b){if(a.className){"string"==qf.typeOf(b)&&(b=b.split(/\\s+/));for(var c=(" "+a.className+" ").replace(/[\n\t\r]/g," "),d=0,e=b.length;d<e;d++)b[d]&&(c=c.replace(" "+b[d]+" "," "));a.className=c.replace(/^\s+/,"").replace(/\s+$/,"")}},
+has:function(a,b){return-1<(" "+a.className+" ").replace(/[\n\t\r]/g," ").indexOf(" "+b+" ")}};qf.events={test:function(){var a={submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1},b=document.createElement("div");if(b.attachEvent)for(var c in{submit:!0,change:!0,focusin:!0}){var d="on"+c,e=d in b;e||(b.setAttribute(d,"return;"),e="function"===typeof b[d]);a[c+"Bubbles"]=e}return a}(),addListener:function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d):a.attachEvent("on"+b,c)},removeListener:function(a,b,c,d){a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent("on"+b,c)},
+fixEvent:function(a){a=a||window.event;a.preventDefault=a.preventDefault||function(){this.returnValue=!1};a.stopPropagation=a.stopPropagation||function(){this.cancelBubble=!0};a.target||(a.target=a.srcElement);!a.relatedTarget&&a.fromElement&&(a.relatedTarget=a.fromElement==a.target?a.toElement:a.fromElement);if(null==a.pageX&&null!=a.clientX){var b=document.documentElement,c=document.body;a.pageX=a.clientX+(b&&b.scrollLeft||c&&c.scrollLeft||0)-(b.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
+c&&c.scrollTop||0)-(b.clientTop||0)}!a.which&&a.button&&(a.which=a.button&1?1:a.button&2?3:a.button&4?2:0);return a}};qf.Rule=function(a,b,c,d){this.callback=a;this.owner=b;this.message=c;this.chained=d||[[]]};qf.LiveRule=function(a,b,c,d,e){qf.Rule.call(this,a,b,c,e);this.triggers=d};qf.LiveRule.prototype=new qf.Rule;qf.LiveRule.prototype.constructor=qf.LiveRule;
+qf.Validator=function(a,b){this.rules=b||[];this.errors=new qf.Map;a.validator=this;qf.events.addListener(a,"submit",qf.Validator.submitHandler);for(var c=0,d;d=this.rules[c];c++)if(d instanceof qf.LiveRule){qf.events.test.changeBubbles?qf.events.addListener(a,"change",qf.Validator.liveHandler,!0):(qf.events.addListener(a,"click",function(a){var a=qf.events.fixEvent(a),c=a.target;("select"==c.nodeName.toLowerCase()||"input"==c.nodeName.toLowerCase()&&("checkbox"==c.type||"radio"==c.type))&&qf.Validator.liveHandler(a)}),
+qf.events.addListener(a,"keydown",function(a){var a=qf.events.fixEvent(a),c=a.target,b="type"in c?c.type:"";(13==a.keyCode&&"textarea"!=c.nodeName.toLowerCase()||32==a.keyCode&&("checkbox"==b||"radio"==b)||"select-multiple"==b)&&qf.Validator.liveHandler(a)}));qf.events.test.focusinBubbles?qf.events.addListener(a,"focusout",qf.Validator.liveHandler,!0):qf.events.addListener(a,"blur",qf.Validator.liveHandler,!0);break}};
qf.Validator.submitHandler=function(a){var a=qf.events.fixEvent(a),b=a.target;b.validator&&!b.validator.run(b)&&a.preventDefault()};qf.Validator.liveHandler=function(a){var a=qf.events.fixEvent(a),b=a.target.form;b.validator&&b.validator.runLive(a)};
-qf.Validator.prototype=function(){function a(a){for(a=document.getElementById(a);!qf.classes.has(a,"element")&&"fieldset"!=a.nodeName.toLowerCase();)a=a.parentNode;qf.classes.remove(a,["error","valid"]);b(a);return a}function b(a){for(var a=a.getElementsByTagName("span"),b=0,c;c=a[b];b++)qf.classes.has(c,"error")&&c.parentNode.removeChild(c)}function c(b,e){b.hasKey(e.owner)&&(b.remove(e.owner),a(e.owner));for(var g=0,f;f=e.chained[g];g++)for(var h=0,i;i=f[h];h++)c(b,i)}return{msgPrefix:"Invalid information entered:",
-msgPostfix:"Please correct these fields.",onStart:function(a){b(a)},onError:function(a,b){this.onFieldError(a,b)},onValid:function(){this.onFormValid()},onInvalid:function(){this.onFormError()},onFieldError:function(b,c){var g=a(b);qf.classes.add(g,"error");var f=document.createElement("span");f.className="error";f.appendChild(document.createTextNode(c));f.appendChild(document.createElement("br"));if("fieldset"!=g.nodeName.toLowerCase())g.insertBefore(f,g.firstChild);else{var h=g.getElementsByTagName("legend");
-0==h.length?g.insertBefore(f,g.firstChild):h[h.length-1].parentNode.insertBefore(f,h[h.length-1].nextSibling)}},onFieldValid:function(b){b=a(b);qf.classes.add(b,"valid")},onFormValid:function(){},onFormError:function(){},run:function(a){this.onStart(a);this.errors.clear();for(var a=0,b;b=this.rules[a];a++)this.errors.hasKey(b.owner)||this.validate(b);return this.errors.isEmpty()?(this.onFormValid(),!0):(this.onFormError(),!1)},runLive:function(a){for(var a=" "+a.target.id+" ",b=new qf.Map,g=-1;b.length()>
-g;)for(var g=b.length(),f=0,h;h=this.rules[f];f++)if(h instanceof qf.LiveRule&&!b.hasKey(f))for(var i=0,j;j=h.triggers[i];i++)if(-1<a.indexOf(" "+j+" ")){b.set(f,!0);c(this.errors,h);a+=h.triggers.join(" ")+" ";break}for(f=0;h=this.rules[f];f++)b.hasKey(f)&&!this.errors.hasKey(h.owner)&&this.validate(h)},validate:function(a){for(var b=!1,c=a.callback.call(this),f=0,h;h=a.chained[f];f++){for(var i=0,j;j=h[i];i++)if(c=c&&this.validate(j),!c)break;if(b=b||c)break;c=!0}if(!b&&a.message&&!this.errors.hasKey(a.owner))this.errors.set(a.owner,
-a.message),this.onFieldError(a.owner,a.message);else if(!this.errors.hasKey(a.owner))this.onFieldValid(a.owner);return b}}}();qf.rules=qf.rules||{};qf.rules.each=function(a){for(var b=0;b<a.length;b++)if(!a[b]())return!1;return!0};qf.rules.empty=function(a){switch(qf.typeOf(a)){case "array":for(var b=0;b<a.length;b++)if(!qf.rules.empty(a[b]))return!1;return!0;case "undefined":case "null":return!0;default:return""==a}};
-qf.rules.nonempty=function(a,b){var c,d=0;if("array"==qf.typeOf(a)){for(c=0;c<a.length;c++)qf.rules.nonempty(a[c],1)&&d++;return d>=b}else if(a instanceof qf.Map){var e=a.getValues();if(1==a.length()){c=a.getKeys()[0];var g=e[0];if("[]"==c.slice(-2)&&"array"==qf.typeOf(g))return qf.rules.nonempty(g,b)}for(c=0;c<e.length;c++)qf.rules.nonempty(e[c],1)&&d++;return d>=b}else return""!=a&&"undefined"!=qf.typeOf(a)&&"null"!=qf.typeOf(a)};
+qf.Validator.prototype=function(){function a(a){for(a=document.getElementById(a);!qf.classes.has(a,"element")&&"fieldset"!=a.nodeName.toLowerCase();)a=a.parentNode;return a}function b(c,d){c.remove(d.owner);var e=a(d.owner);qf.classes.remove(e,["error","valid"]);for(var e=e.getElementsByTagName("span"),f=e.length-1;0<=f;f--)qf.classes.has(e[f],"error")&&e[f].parentNode.removeChild(e[f]);for(e=0;f=d.chained[e];e++)for(var g=0,h;h=f[g];g++)b(c,h)}return{onStart:function(){for(var a=0,d;d=this.rules[a];a++)b(this.errors,
+d)},onFieldError:function(b,d){var e=a(b);qf.classes.add(e,"error");var f=document.createElement("span");f.className="error";f.appendChild(document.createTextNode(d));f.appendChild(document.createElement("br"));if("fieldset"!=e.nodeName.toLowerCase())e.insertBefore(f,e.firstChild);else{var g=e.getElementsByTagName("legend");0==g.length?e.insertBefore(f,e.firstChild):g[g.length-1].parentNode.insertBefore(f,g[g.length-1].nextSibling)}},onFieldValid:function(b){qf.classes.add(a(b),"valid")},onFormValid:function(){},
+onFormError:function(){},run:function(a){this.onStart(a);this.errors.clear();for(var a=0,b;b=this.rules[a];a++)this.errors.hasKey(b.owner)||this.validate(b);if(this.errors.isEmpty())return this.onFormValid(),!0;this.onFormError();return!1},runLive:function(a){for(var a=" "+a.target.id+" ",d=new qf.Map,e=-1;d.length()>e;)for(var e=d.length(),f=0,g;g=this.rules[f];f++)if(g instanceof qf.LiveRule&&!d.hasKey(f))for(var h=0,i;i=g.triggers[h];h++)if(-1<a.indexOf(" "+i+" ")){d.set(f,!0);b(this.errors,g);
+a+=g.triggers.join(" ")+" ";break}for(f=0;g=this.rules[f];f++)d.hasKey(f)&&!this.errors.hasKey(g.owner)&&this.validate(g)},validate:function(a){for(var b=!1,e=a.callback.call(this),f=0,g;g=a.chained[f];f++){for(var h=0,i;(i=g[h])&&!(e=e&&this.validate(i),!e);h++);if(b=b||e)break;e=!0}if(!b&&a.message&&!this.errors.hasKey(a.owner))this.errors.set(a.owner,a.message),this.onFieldError(a.owner,a.message);else if(!this.errors.hasKey(a.owner))this.onFieldValid(a.owner);return b}}}();qf.rules=qf.rules||{};qf.rules.each=function(a){for(var b=0;b<a.length;b++)if(!a[b]())return!1;return!0};qf.rules.empty=function(a){switch(qf.typeOf(a)){case "array":for(var b=0;b<a.length;b++)if(!qf.rules.empty(a[b]))return!1;return!0;case "undefined":case "null":return!0;default:return""==a}};
+qf.rules.nonempty=function(a,b){var c,d=0;if("array"==qf.typeOf(a)){for(c=0;c<a.length;c++)qf.rules.nonempty(a[c],1)&&d++;return d>=b}if(a instanceof qf.Map){var e=a.getValues();if(1==a.length()){c=a.getKeys()[0];var f=e[0];if("[]"==c.slice(-2)&&"array"==qf.typeOf(f))return qf.rules.nonempty(f,b)}for(c=0;c<e.length;c++)qf.rules.nonempty(e[c],1)&&d++;return d>=b}return""!=a&&"undefined"!=qf.typeOf(a)&&"null"!=qf.typeOf(a)};
View
30 data/js/quickform-hierselect.js
@@ -3,8 +3,8 @@
* Package version @package_version@
* http://pear.php.net/package/HTML_QuickForm2
*
- * Copyright 2006-2011, Alexey Borzov, Bertrand Mansion
- * Licensed under new BSD license
+ * Copyright 2006-2012, Alexey Borzov, Bertrand Mansion
+ * Licensed under new BSD license
* http://opensource.org/licenses/bsd-license.php
*/
@@ -43,7 +43,7 @@ qf.elements.hierselect = (function(){
}
}, 1);
};
- };
+ }
/**
* Returns 'onload' handler for page containing hierselect.
@@ -69,13 +69,13 @@ qf.elements.hierselect = (function(){
qf.form.setValue(next[i], defaults[i + 1]);
}
};
- };
+ }
/**
* Stores options for a select element in options object.
- *
+ *
* Useful mostly for asynchronous requests.
- *
+ *
* @param {String} selectId ID attribute of first select element
* @param {Array} keys Values of previous select elements
* @param {Object} options New options
@@ -101,7 +101,7 @@ qf.elements.hierselect = (function(){
ary = ary[key];
}
}
- };
+ }
/**
* The 'onchange' handler for selects, replaces the options of subsequent select(s).
@@ -114,7 +114,7 @@ qf.elements.hierselect = (function(){
if (event.target.hierselect && 0 != event.target.hierselect.next.length) {
qf.elements.hierselect.cascade.call(event.target);
}
- };
+ }
return {
/**
@@ -122,7 +122,7 @@ qf.elements.hierselect = (function(){
*
* @param {Array} selects IDs of select elements in hierselect
* @param {Function} optionsCallback function that will be called to
- * get missing options (presumably via AJAX)
+ * get missing options (presumably via AJAX)
*/
init: function(selects, optionsCallback)
{
@@ -145,7 +145,7 @@ qf.elements.hierselect = (function(){
/**
* Gets the value for a hierselect element.
- *
+ *
* @param {String[]} selects Array of selects' ID attributes
* @returns {Array}
*/
@@ -162,9 +162,9 @@ qf.elements.hierselect = (function(){
* Replaces options of a select element.
*
* Options are provided in such a way rather than as {value: text, ...} object
- * due to the fact that browsers can iterate over an object with a 'for in'
- * loop in random order (see bug).
- *
+ * due to the fact that browsers can iterate over an object with a 'for in'
+ * loop in random order (see bug).
+ *
* @see <a href="http://pear.php.net/bugs/bug.php?id=16603">PEAR bug #16603</a>
* @param {Element} ctl Select element
* @param {Object} options New options
@@ -191,7 +191,7 @@ qf.elements.hierselect = (function(){
/**
* Finds options for next select element in hierselect.
- *
+ *
* @param {String} selectId ID attribute of first select element
* @param {Array} keys Values of previous select elements
* @param {Function} callback Function to use for loading additional options
@@ -268,7 +268,7 @@ qf.elements.hierselect = (function(){
/**
* Options cache for second and subsequent selects in hierselect. Keyed by
- * ID attribute of first select in chain.
+ * ID attribute of first select in chain.
* @type {Object}
*/
options: {},
View
163 data/js/quickform.js
@@ -3,8 +3,8 @@
* Package version @package_version@
* http://pear.php.net/package/HTML_QuickForm2
*
- * Copyright 2006-2011, Alexey Borzov, Bertrand Mansion
- * Licensed under new BSD license
+ * Copyright 2006-2012, Alexey Borzov, Bertrand Mansion
+ * Licensed under new BSD license
* http://opensource.org/licenses/bsd-license.php
*/
@@ -27,7 +27,7 @@ qf.elements = qf.elements || {};
* like objects passed across browser windows, etc. Borrowed from closure library.
*
* @param {*} value The value to get the type of
- * @returns {string} Type name
+ * @returns {string} Type name
*/
qf.typeOf = function(value) {
var s = typeof value;
@@ -70,7 +70,7 @@ qf.typeOf = function(value) {
* "a.b.c" -> a = {};a.b={};a.b.c={};
* </code>
* Borrowed from closure library.
- *
+ *
* @param {string} ns name of the object that this file defines.
*/
qf.addNamespace = function(ns) {
@@ -134,7 +134,7 @@ qf.Map.prototype = (function(){
function _hasKey(obj, key)
{
return Object.prototype.hasOwnProperty.call(obj, key);
- };
+ }
/**
* Removes keys that are no longer in the map from the _keys array
@@ -159,7 +159,7 @@ qf.Map.prototype = (function(){
srcIndex++;
}
this._keys.length = destIndex;
- };
+ }
return {
/**
@@ -216,7 +216,7 @@ qf.Map.prototype = (function(){
},
/**
- * Removes all key-value pairs from the map
+ * Removes all key-value pairs from the map
*/
clear: function()
{
@@ -257,7 +257,7 @@ qf.Map.prototype = (function(){
}
return defaultVal;
},
-
+
/**
* Adds a key-value pair to the Map
* @param {*} key
@@ -275,7 +275,7 @@ qf.Map.prototype = (function(){
/**
* Merges key-value pairs from another Object or Map
* @param {Object} map
- * @param {function(*, *)} [mergeFn] Optional function to call on values if
+ * @param {function(*, *)} [mergeFn] Optional function to call on values if
* both maps have the same key. By default a value from the map being
* merged will be stored under that key.
*/
@@ -309,9 +309,9 @@ qf.Map.prototype = (function(){
/**
* Callback for merge(), forces to use second value.
- *
+ *
* This makes Map.merge() behave like PHP's array_merge() function
- *
+ *
* @param {*} a Original value in map
* @param {*} b Value in the map being merged
* @returns {*} second value
@@ -323,9 +323,9 @@ qf.Map.mergeReplace = function(a, b)
/**
* Callback for merge(), forces to use first value.
- *
+ *
* This makes Map.merge() behave like PHP's + operator for arrays
- *
+ *
* @param {*} a Original value in map
* @param {*} b Value in the map being merged
* @returns {*} first value
@@ -338,8 +338,8 @@ qf.Map.mergeKeep = function(a, b)
/**
* Callback for merge(), concatenates values.
*
- * If the values are not arrays, they are first converted to ones.
- *
+ * If the values are not arrays, they are first converted to ones.
+ *
* This callback makes Map.merge() behave somewhat like PHP's array_merge_recursive()
*
* @param {*} a Original value in map
@@ -377,8 +377,8 @@ qf.form = (function() {
}
}
return values;
- };
-
+ }
+
/**
* Sets the value of a select-one element.
* @param {Element} el
@@ -394,7 +394,7 @@ qf.form = (function() {
return;
}
}
- };
+ }
/**
* Sets the value of a select-multiple element.
@@ -420,7 +420,7 @@ qf.form = (function() {
return {
/**
* Gets the value of a form element.
- *
+ *
* @param {string|Element} el
* @returns {string|string[]|null}
*/
@@ -475,22 +475,22 @@ qf.form = (function() {
*
* @param [...] This accepts a variable number of arguments, that are either
* strings (considered element ID attributes), objects {name: element name,
- * value: element value} or instances of qf.Map, representing the contained elements
+ * value: element value} or instances of qf.Map, representing the contained elements
* @returns qf.Map
*/
getContainerSubmitValue: function()
{
- var map = new qf.Map();
+ var k, v, map = new qf.Map();
for (var i = 0; i < arguments.length; i++) {
if (arguments[i] instanceof qf.Map) {
map.merge(arguments[i], qf.Map.mergeArrayConcat);
} else {
if ('object' == qf.typeOf(arguments[i])) {
- var k = arguments[i].name;
- var v = arguments[i].value;
+ k = arguments[i].name;
+ v = arguments[i].value;
} else {
- var k = document.getElementById(arguments[i]).name;
- var v = qf.form.getSubmitValue(arguments[i]);
+ k = document.getElementById(arguments[i]).name;
+ v = qf.form.getSubmitValue(arguments[i]);
}
if (null !== v) {
var valueObj = {};
@@ -607,10 +607,7 @@ qf.classes = {
*/
has: function(element, name)
{
- if (-1 < (' ' + element.className + ' ').replace(/[\n\t\r]/g, ' ').indexOf(' ' + name + ' ')) {
- return true;
- }
- return false;
+ return (-1 < (' ' + element.className + ' ').replace(/[\n\t\r]/g, ' ').indexOf(' ' + name + ' '));
}
};
@@ -827,9 +824,9 @@ qf.Validator = function(form, rules)
qf.events.addListener(form, 'click', function (event) {
event = qf.events.fixEvent(event);
var el = event.target;
- if ('select' == el.nodeName.toLowerCase()
- || 'input' == el.nodeName.toLowerCase()
- && ('checkbox' == el.type || 'radio' == el.type)
+ if ('select' == el.nodeName.toLowerCase()
+ || 'input' == el.nodeName.toLowerCase()
+ && ('checkbox' == el.type || 'radio' == el.type)
) {
qf.Validator.liveHandler(event);
}
@@ -857,7 +854,7 @@ qf.Validator = function(form, rules)
};
/**
- * Event handler for form's onsubmit events.
+ * Event handler for form's onsubmit events.
* @param {Event} event
*/
qf.Validator.submitHandler = function(event)
@@ -885,7 +882,7 @@ qf.Validator.liveHandler = function (event)
qf.Validator.prototype = (function() {
/**
* Clears validation status and error message of a given element
- *
+ *
* @param {string} elementId
* @returns {Node} Parent element that gets 'error' / 'valid'
* classes applied
@@ -893,32 +890,37 @@ qf.Validator.prototype = (function() {
*/
function _clearValidationStatus(elementId)
{
- var el = document.getElementById(elementId), parent = el;
- while (!qf.classes.has(parent, 'element') && 'fieldset' != parent.nodeName.toLowerCase()) {
- parent = parent.parentNode;
- }
+ var parent = _findParent(elementId);
qf.classes.remove(parent, ['error', 'valid']);
- _clearErrors(parent);
+ var spans = parent.getElementsByTagName('span');
+ for (var i = spans.length - 1; i >= 0; i--) {
+ if (qf.classes.has(spans[i], 'error')) {
+ spans[i].parentNode.removeChild(spans[i]);
+ }
+ }
return parent;
- };
+ }
/**
- * Removes <span> elements with "error" class that are children of a given element
- *
- * @param {Node} element
+ * Returns the first ancestor of an element that is either a fieldset or has class "element"
+ *
+ * @param {string} elementId
+ * @returns {Node}
+ *
* @private
*/
- function _clearErrors(element)
+ function _findParent(elementId)
{
- var spans = element.getElementsByTagName('span');
- for (var i = 0, span; span = spans[i]; i++) {
- if (qf.classes.has(span, 'error')) {
- span.parentNode.removeChild(span);
- }
+ var parent = document.getElementById(elementId);
+ while (!qf.classes.has(parent, 'element')
+ && 'fieldset' != parent.nodeName.toLowerCase()
+ ) {
+ parent = parent.parentNode;
}
- };
+ return parent;
+ }
/**
* Removes error messages from owner element(s) of a given rule and chained rules
@@ -929,67 +931,25 @@ qf.Validator.prototype = (function() {
*/
function _removeRelatedErrors(errors, rule)
{
- if (errors.hasKey(rule.owner)) {
- errors.remove(rule.owner);
- _clearValidationStatus(rule.owner);
- }
+ errors.remove(rule.owner);
+ _clearValidationStatus(rule.owner);
for (var i = 0, item; item = rule.chained[i]; i++) {
for (var j = 0, multiplier; multiplier = item[j]; j++) {
_removeRelatedErrors(errors, multiplier);
}
}
- };
+ }
return {
/**
- * Message prefix in alert in case of failed validation
- * @type {String}
- */
- msgPrefix: 'Invalid information entered:',
-
- /**
- * Message postfix in alert in case of failed validation
- * @type {String}
- */
- msgPostfix: 'Please correct these fields.',
-
- /**
* Called before starting the validation. May be used e.g. to clear the errors from form elements.
* @param {HTMLFormElement} form The form being validated currently
*/
- onStart: function(form)
- {
- _clearErrors(form);
- },
-
- /**
- * Called on setting the element error
- *
- * @param {string} elementId ID attribute of an element
- * @param {string} errorMessage
- * @deprecated Use onFieldError() instead
- */
- onError: function(elementId, errorMessage)
- {
- this.onFieldError(elementId, errorMessage);
- },
-
- /**
- * Called on successfully validating the form
- * @deprecated Use onFormValid() instead
- */
- onValid: function()
+ onStart: function(form)
{
- this.onFormValid();
- },
-
- /**
- * Called on failed validation
- * @deprecated Use onFormError() instead
- */
- onInvalid: function()
- {
- this.onFormError();
+ for (var i = 0, rule; rule = this.rules[i]; i++) {
+ _removeRelatedErrors(this.errors, rule);
+ }
},
/**
@@ -1000,7 +960,7 @@ qf.Validator.prototype = (function() {
*/
onFieldError: function(elementId, errorMessage)
{
- var parent = _clearValidationStatus(elementId);
+ var parent = _findParent(elementId);
qf.classes.add(parent, 'error');
var error = document.createElement('span');
@@ -1027,8 +987,7 @@ qf.Validator.prototype = (function() {
*/
onFieldValid: function(elementId)
{
- var parent = _clearValidationStatus(elementId);
- qf.classes.add(parent, 'valid');
+ qf.classes.add(_findParent(elementId), 'valid');
},
/**
View
8 js/src/base.js
@@ -3,8 +3,8 @@
* Package version @package_version@
* http://pear.php.net/package/HTML_QuickForm2
*
- * Copyright 2006-2011, Alexey Borzov, Bertrand Mansion
- * Licensed under new BSD license
+ * Copyright 2006-2012, Alexey Borzov, Bertrand Mansion
+ * Licensed under new BSD license
* http://opensource.org/licenses/bsd-license.php
*/
@@ -27,7 +27,7 @@ qf.elements = qf.elements || {};
* like objects passed across browser windows, etc. Borrowed from closure library.
*
* @param {*} value The value to get the type of
- * @returns {string} Type name
+ * @returns {string} Type name
*/
qf.typeOf = function(value) {
var s = typeof value;
@@ -70,7 +70,7 @@ qf.typeOf = function(value) {
* "a.b.c" -> a = {};a.b={};a.b.c={};
* </code>
* Borrowed from closure library.
- *
+ *
* @param {string} ns name of the object that this file defines.
*/
qf.addNamespace = function(ns) {
View
2  js/src/hierselect.js
@@ -3,7 +3,7 @@
* Package version @package_version@
* http://pear.php.net/package/HTML_QuickForm2
*
- * Copyright 2006-2011, Alexey Borzov, Bertrand Mansion
+ * Copyright 2006-2012, Alexey Borzov, Bertrand Mansion
* Licensed under new BSD license
* http://opensource.org/licenses/bsd-license.php
*/
View
46 js/src/validator.js
@@ -163,31 +163,36 @@ qf.Validator.prototype = (function() {
*/
function _clearValidationStatus(elementId)
{
- var el = document.getElementById(elementId), parent = el;
- while (!qf.classes.has(parent, 'element') && 'fieldset' != parent.nodeName.toLowerCase()) {
- parent = parent.parentNode;
- }
+ var parent = _findParent(elementId);
qf.classes.remove(parent, ['error', 'valid']);
- _clearErrors(parent);
+ var spans = parent.getElementsByTagName('span');
+ for (var i = spans.length - 1; i >= 0; i--) {
+ if (qf.classes.has(spans[i], 'error')) {
+ spans[i].parentNode.removeChild(spans[i]);
+ }
+ }
return parent;
}
/**
- * Removes <span> elements with "error" class that are children of a given element
+ * Returns the first ancestor of an element that is either a fieldset or has class "element"
+ *
+ * @param {string} elementId
+ * @returns {Node}
*
- * @param {Node} element
* @private
*/
- function _clearErrors(element)
+ function _findParent(elementId)
{
- var spans = element.getElementsByTagName('span');
- for (var i = 0, span; span = spans[i]; i++) {
- if (qf.classes.has(span, 'error')) {
- span.parentNode.removeChild(span);
- }
+ var parent = document.getElementById(elementId);
+ while (!qf.classes.has(parent, 'element')
+ && 'fieldset' != parent.nodeName.toLowerCase()
+ ) {
+ parent = parent.parentNode;
}
+ return parent;
}
/**
@@ -199,10 +204,8 @@ qf.Validator.prototype = (function() {
*/
function _removeRelatedErrors(errors, rule)
{
- if (errors.hasKey(rule.owner)) {
- errors.remove(rule.owner);
- _clearValidationStatus(rule.owner);
- }
+ errors.remove(rule.owner);
+ _clearValidationStatus(rule.owner);
for (var i = 0, item; item = rule.chained[i]; i++) {
for (var j = 0, multiplier; multiplier = item[j]; j++) {
_removeRelatedErrors(errors, multiplier);
@@ -217,7 +220,9 @@ qf.Validator.prototype = (function() {
*/
onStart: function(form)
{
- _clearErrors(form);
+ for (var i = 0, rule; rule = this.rules[i]; i++) {
+ _removeRelatedErrors(this.errors, rule);
+ }
},
/**
@@ -228,7 +233,7 @@ qf.Validator.prototype = (function() {
*/
onFieldError: function(elementId, errorMessage)
{
- var parent = _clearValidationStatus(elementId);
+ var parent = _findParent(elementId);
qf.classes.add(parent, 'error');
var error = document.createElement('span');
@@ -255,8 +260,7 @@ qf.Validator.prototype = (function() {
*/
onFieldValid: function(elementId)
{
- var parent = _clearValidationStatus(elementId);
- qf.classes.add(parent, 'valid');
+ qf.classes.add(_findParent(elementId), 'valid');
},
/**
Please sign in to comment.
Something went wrong with that request. Please try again.