diff --git a/src/validator.js b/src/validator.js index f281010..56b0f2c 100644 --- a/src/validator.js +++ b/src/validator.js @@ -88,10 +88,11 @@ }; Validator.prototype.getErrorMessageElement = function() { - var $el = this.opts.$applyElement, - $prev = $el.prev( '.error-msg' ); + var callback = this.opts.getErrorAnchor, + $anchor = callback ? callback.call( this ) : this.opts.$applyElement, + $prev = $anchor.prev( '.error-msg' ); - return $prev.length ? $prev : $( '
' ).addClass( 'error-msg' ).insertBefore( $el ); + return $prev.length ? $prev : $( '
' ).addClass( 'error-msg' ).insertBefore( $anchor ); }; /*