Actually, thinking about this, yeah, there's gonna be a loop.
onElementValidate is fired whenever an inputs validators are applied,
whether it's valid or not. So when you call myForm.validate() inside that,
it's just going to go validate that input again and fire your event handler
again and repeat.
You'll have to set a conditional flag for when it's YOU doing the validating
vs the user's action. Something like:
var iAmValidating = false;
myValidator.addEvent('onElementValidate', function(){
if (!IAmValidating) {
iAmValidating = true;
if (myValidator.validate()) ...
iAmValidating = false;
}
});
A little clunky I realize.
On Thu, May 19, 2011 at 2:53 AM, Arian Stolwijk <[email protected]> wrote:
> isn't onElementValidate only fired when the form is actually valid.
>
>
> On Thu, May 19, 2011 at 11:16 AM, hamburger <[email protected]> wrote:
>
>> thx Aaron,
>> but how to grab the whole form elements. The function do not give
>> them.
>>
>> onElementValidate: function(passed,element,validator,denotes ) {
>>
>> if ( myForm.validate() ){ console.log("something wrong")};
>>
>> },
>>
>> gives the error to much recursion
>
>
>