I'm having a little bit of difficulty trying to do this cleanly, and the majority of docs/posts I've seen about this typically involve adding a new custom validation method. I want to just add an extra piece of functionality to the existing validate() method to capture when form validation is failed. If I extend the class, it seems like I would have to duplicate the full validate() function (I may be wrong here but that was the result I was getting). I could just do that but I'm sure it can't be the best way to handle this.
It looks like what I'm after is wrapping the existing function with the additional functionality I want to add. However this is throwing an error.
My code is currently:
Validation.prototype.validate = Validation.prototype.validate.wrap(function(parentMethod){
parentMethod();
// I want to add some logic here when validation errors have been triggered
});
The above code generates the following error: prototype.js:429 Uncaught TypeError: wrapper.apply is not a function
Any help much appreciated!
Validation.addAllThese(....