The init
method only supports overriding configuration properties, so if you want to override methods you need to do it directly on the ko.validation
object.
So your initialization code should look like this:
ko.validation.init({
// registerExtenders: true,
messagesOnModified: false,
insertMessages: true,
parseInputAttributes: true,
messageTemplate: null,
grouping: { deep: true, observable: true },
registerExtenders: true
});
ko.validation.insertValidationMessage = function (element) {
var span = document.createElement('SPAN');
span.className = "validationMessage";
if ($(element).hasClass("error-before"))
element.parentNode.insertBefore(span, element);
else
element.parentNode.insertBefore(span, element.nextSibling);
return span;
};