Although the answer is accepted, but I would like to share my approach. I prefer to combine jquery with knockout.js and apply the jQuery Validation plugin that suits very well for unobtrusive client-side form validation. It works prior to the form submission and accepts the form as an input parameter.
Something like this:
function ViewModel() {
var self = this;
self.firstName = ko.observable();
self.lastName = ko.observable();
self.email = ko.observable();
self.validate = function(form) {
return $(form).validate();
};
};
var viewModel = new ViewModel();
ko.applyBindings(viewModel);
The validate() function is called If the validation succeeds, the form will be submitted, otherwise, an error will be displayed.