Validation 淘汰验证组错误
我试图将firstName、lastName和EmailAddess设置为要验证的观察值组 我一直得到的错误是“ChecklistForm未定义” 更新的视图模型:-Validation 淘汰验证组错误,validation,knockout.js,Validation,Knockout.js,我试图将firstName、lastName和EmailAddess设置为要验证的观察值组 我一直得到的错误是“ChecklistForm未定义” 更新的视图模型:- function checklistFormModel() { var ChecklistForm = { something: ko.observable(false), somethingElse: function () {}, firstName: ko.observable().exten
function checklistFormModel() {
var ChecklistForm = {
something: ko.observable(false),
somethingElse: function () {},
firstName: ko.observable().extend({
minLength: 2,
maxLength: 10
}),
lastName: ko.observable().extend({
minLength: 2,
maxLength: 10
}),
emailAddress: ko.observable().extend({
email: true
}),
group: ko.validatedObservable({
firstName: this.firstName,
lastName: this.lastName,
emailAddress: this.emailAddress
}),
submitForm: function () {
console.log(this.group.errors());
console.log(this.group.isValid());
}
}
return ChecklistForm;
}
ko.applyBindings(checklistFormModel);
function checklistFormModel() {
var ChecklistForm = {
something: ko.observable(false),
somethingElse: function () {},
firstName: ko.observable().extend({
minLength: 2,
maxLength: 10
}),
lastName: ko.observable().extend({
minLength: 2,
maxLength: 10
}),
emailAddress: ko.observable().extend({
email: true
}),
group: ko.validatedObservable({
firstName: this.firstName,
lastName: this.lastName,
emailAddress: this.emailAddress
}),
submitForm: function () {
console.log(this.group.errors());
console.log(this.group.isValid());
}
}
return ChecklistForm;
}
ko.applyBindings(checklistFormModel);