0

I try to add knockout validation on my page.

I see an example here: How to use ko.validation.group function

But my code is somewhat different, see below:

define(function (require) {

var datacontext = require('services/datacontext'),
    app = require('durandal/app');

var transport = ko.observable(),
    errors = ko.validation.group(transport);

....
....

ko.validation.configure({
    decorateElement: true
});

var vm = {
    transport: transport,
    errors: errors,
    activate: activate,
    canSave: canSave,
    save: save,
    cancel: cancel
};

return vm;
});

Where 'transport' is the object containing properties to validate.

At runtime I don't have any errors but it doesn't work: the errors object is always valid event if I really have errors (missing value) on my input elements.

Any idea?

Community
  • 1
  • 1
Bronzato
  • 9,438
  • 29
  • 120
  • 212

1 Answers1

0

Try this

vm["errors"] = ko.validation.group(transport);
MikeW
  • 4,749
  • 9
  • 42
  • 83