validatingForm.lzx
<library>
<class name="validatingForm" extends="form" initstage="late">
<attribute name="validators"/>
<attribute name="errorcount" type="number" value="0
"/>
<handler name="oninit" method="classinit"/>
<method name="classinit" args="ignore">
this.errors = new Array();
this.validators = new Array();
recursive(this);
this.clearErrors();
</method>
<method name="clearErrors">
for(var i = 0; i < this.validators.length; i++){
this.validators[i].cleanErrors();
}
</method>
<method name="recursive" args="newsub">
for( var i = 0; i < newsub.subnodes.length ; i++ ){
if( newsub.subnodes[i].subnodes ){
if( 0 < newsub.subnodes[i].subnodes.length )
recursive(newsub.subnodes[i]);
}
addevents(newsub.subnodes[i]);
}
</method>
<method name="addevents" args="obj">
if(typeof obj.isformvalidator != "undefined"){
if(obj.isformvalidator == true){
new lz.Delegate( this, "iserrorchanged", obj, "oniserror");
this.validators.push(obj);
}
}
</method>
<method name="iserrorchanged" args="ignore=true">
var count = 0;
for(var i = 0; i < this.validators.length; i++){
if(this.validators[i].iserror){
count ++;
}
}
if(count != this.errorcount)
this.setAttribute("errorcount", count);
</method>
</class>
</library>