Hey TD -
When registering an object for validation, it would be much more efficient to do it all in one call rather than several - and in looking back at my code I also would have required parsing. Since there is no limit to the number of arguments you can pass on a JS function call, this would make sense:
validator.register('itemname', 'trim', 'notnull', 'isalpha');
In the function, the arguments reserved array holds all of what was passed - you can iterate with a simple for loop:
for (var i=0; i<arguments.length; i++) { doSomethingWith(arguments[i]); }
The only thing this does not address is when you want to do something more exotic, like register a regex to check against - you need to both instruct the obhect that you want to use a regex, and what the regex is - so this syntax needs to be rethunk.
Your code:
validator.registerRule( 'some_new_rule', 'element > 1000' );
validator.addRule( 'itemname', 'some_new_rule' );
creeps me out. This is because a parser and evaluator that is actually smart enough to make that sort of thing work, and yet is efficient enough to do things quickly will be quite an effort. I've written several languages in my day... so I have a reasonable amount of experience with that sort of thing. Since classes are easily extended, it would seem to me to simply add a new function prototype if you need something special - and have all the best and most used available on the class stock.
Along the lines of this but nowhere near as comprehensive (least not at this stage ;-) ) http:// pear.php.net/manual/en/package.html.html-quickform.php
That's some big mocassins to fill keemosabe...

We may not even need to catch the onchange, merely validate on submission? If we extrapolate the functionality of the validation engine we would have to provide a mechanism to specify what happens on validation failure, perhaps template based? Then we need to consider whether we would use a conventional POST for the form or consider using AJAX to get the form data back to the server and supply the appropriate response? What I like about using AJAX is that if the form submission failed for whatever reasons you could provide some level of redundancy such as drop back to a conventional post to an alternate location, etc.
In that case we would need another function to vector the onsubmit function of the form we were watching. This is pretty easy - we could:
validator.registerForm('formIDNotName');
and then in that function we set the onSubmit attribute to be <this> so that we can allow or disallow the submission.
That makes sense provided someone is always using forms for their work... I never do. I wrap things in a form only if I have to. When you start thinking AJAX you stop thinking forms and element names and start thinking visible divs and element IDs. No need for forms at all... in which case you'd need to either hook a button or let the coder hook it himself:
<input type="button" value="Do It" onClick="if (validator.goodToGo()) { document.formName.submit; }">
however that is largely inelegant.
Agree - this could morph into something rather cool and definitely usable...
/p