I have a knockout form that is comprised of 2 parts. When the first part is being filled out the second part is hidden. Upon completing the first part and clicking "Continue" the first part is then hidden and the second part is shown. I want to be able to validate the first set of inputs, and if there are no errors then continue to the next part.
I found this on the official github page which I is what I'm attempting to do.
When I do this no errors are detected. It continues to the second part
function ReserveViewModel(){
self.firstName = ko.observable("").extend({ required: true });
self.continue = function(){
var errors = ko.validation.group([ReserveViewModel.firstName]);
if (errors.length == 0) {
//display second div
}
else{
self.errors.showAllMessages();
}
}
}
However, if I do this it works but tries to validate everything. Since the second set of inputs are empty it just hangs there.
self.continue = function(){
self.errors = ko.validation.group(self);
if (self.errors().length == 0) {
}
else{
self.errors.showAllMessages();
}
}