我正在尝试进行淘汰赛,但无法使用淘汰赛验证插件进行验证。[编辑:更新小提琴]示例小提琴:jsfiddle.net/EHDD8
var CustVM = function () {
var self = this;
self.name = ko.observable().extend({ required: "Name is required" });
self.contact = ko.observable();
self.phone1 = ko.observable();
self.email = ko.observable().extend({email: true});
self.website = ko.observable().extend({required: "Website is required"});
self.Errors = ko.validation.group(self);
self.save = function () {
if (self.isValid()) {
alert("no error");
}
else {
alert("error");
}
alert("save clicked ");
};
self.cancel = function() {
alert("cancel clicked");
};
};
ko.applyBindings(new CustVM());
即使我没有输入任何必需的元素,isValid 也是如此。