出于某些奇怪的原因,敲除验证不起作用。
这是我的代码:
var searchViewModel = function () {
this.priceTo = ko.observable();
...
}
var searchVM = new searchViewModel();
searchViewModel["errors"] = ko.validation.group(searchViewModel );
var validationOptions = {
insertMessages: true,
decorateElement: true,
errorElementClass: "errorFill",
errorMessageClass: "errorFill"
};
ko.validation.init(validationOptions);
ko.applyBindings(searchVM, $("#searchSection")[0]);
我也尝试修改
searchViewModel["errors"] = ko.validation.group(searchViewModel);
像这样:
searchVM["errors"] = ko.validation.group(searchVM);
没有任何结果。