私は次のように定義されたビューモデルを持っています:
var ViewModel = function() {
var self = this;
self.name = ko.observable().extend({ required: true });
self.identityCode = ko.observable().extend({ required: true, maxLength: 18, minLength: 15 });
self.gender = ko.computed(function() {
// get gender information from the identiy code here
});
self.birthdate = ko.computed(function() {
// get birthdate information from the identity code here
});
self.form_onsubmit = function (form) {
if (!self.isValid()) {
self.errors.showAllMessages();
return false;
} else {
return true;
}
};
};
上記のコードを見るとわかるように、性別フィールドと生年月日フィールドは、ID コードから取得される計算フィールドです。実行する前に、ID コードの検証結果を取得する方法を知りたいだけです。ありがとう!