I have asp.net mvc project where I use knockout.js and knockout validation. The problem is: the validation starts working even before the user can potentially make any action, e.g.: for example I have a field FirstName which is marked as required. But when the user opens the page with this field, there is already the error message saying that this field is empty. Please advise how can I fix it?
here are the additional details:
var searchViewModel = function () {
this.firstName = ko.observable("").extend({ required: { message: "First Name is required", params: true } });
...
this.errors = ko.validation.group(this);
}
var validationOptions = { insertMessages: true, decorateElement: true, errorElementClass: 'errorFill', errorMessageClass: "errorFill" };
ko.validation.init(validationOptions);
var searchVM = new searchViewModel();
ko.applyBindings(searchVM, $("#searchSection")[0]);
And the viewmodel fields are binded to the textboxes in a bootstrap modal window. So when I open my modal I already see the error messages