Search code examples
knockout.jsknockout-validation

Error on Validation Message databind


I am working in big application, having too many view models. I want to display my message in custom location. I have find these tutorials online

http://jsfiddle.net/internetH3ro/tLN7r/

http://jsfiddle.net/Y85Kh/ .

When i tried to implement i am getting the error "VMData is not defined" then I thought of calling it from the view model(viewmodel.VMData) .there I was getting the error "Message: Cannot call method 'extend' of undefined". Is there I am missing something or I need add anything extra to make it accessible while using different view models.

var data = {
    Name: 'test'
};

ko.validation.configure({
    registerExtenders: true,
    messagesOnModified: false,
    insertMessages: false,
    parseInputAttributes: false,
    messageTemplate: null
});

Added : http://jsfiddle.net/udp2z/1/


Solution

  • i saw your code, you can not use validationMessage any where other then under foreach loop it must be in in tbody. In configuration make insertMessages false.

        <tr>
            <td colspan="4"> <span data-bind="validationMessage: Type"></span>
           </td>
        </tr>
    

    Fiddle Demo