Questions tagged [knockout-validation]

A plugin for knockout.js for declarative, rule-based validation of models and properties.

Knockout Validation allows for validation of knockout.js view model observables through extenders with:

The plugin also supports Asynchronous Validation.

Examples of such extensions include:

var myValue = ko.observable().extend({ required: true });
var myValue = ko.observable().extend({ max: 10 });
513 questions
48
votes
3 answers

Knockout validation

I have asp.net mvc3 project where I do a bulk edit on a table with knockout binding. I want to do validations like required and number validations while saving data. Is there any easier way to do knock out validations. PS: I am not using forms.
Kurkula
  • 6,386
  • 27
  • 127
  • 202
21
votes
3 answers

Knockout Validation evaluates immediately on load

I'm using MVC, Knockout, and Knockout Validation to validate my view model. I'm running into an issue where the validation for view model properties are firing immediately upon loading. In other words, "This field is required" shows up next to my…
letsgetsilly
  • 1,156
  • 2
  • 11
  • 27
21
votes
3 answers

Set a custom error message using the native rules of the knockout validation plugin

I am using Asp.net MVC3 and knockoutjs library. I need to do some client side validation. I am exploring the knockout validation plugin. So I declare the following ko.observable value in my js code: var numberValue = ko.observable().extend({…
Mdb
  • 8,338
  • 22
  • 63
  • 98
20
votes
2 answers

How to remove extender from an existing observable?

I am using the Knockout Validation plugin and setting an observable as required using the extender: myObservable.extend({required:true}); Is it possible for me to remove the extender after adding it?
Jonas Stawski
  • 6,682
  • 6
  • 61
  • 106
20
votes
2 answers

Knockout Mapping Validation

I'm trying to attach validation to a mapped view. I'm using Knockout Mapping and Validation plugins. Pseudo-models: Person { int Id; string Name; Book[] Books; } Book { int Id; string Name; } Javascript: function viewModel() { …
19
votes
1 answer

KnockoutValidation and the conditional required rule

I am trying to use KnockoutValidation with conditional statements. See code below: self.transactionType = ko.observable('Option1'); self.ConditionalField = ko.observable().extend({ required: true, onlyIf: self.transactionType =…
Mounhim
  • 1,674
  • 1
  • 17
  • 32
18
votes
1 answer

Knockout Validation - How to show error messages

We're using Knockout.js and the Knockout-validation plugin. When a user returns to a page that has validation errors, we want the error messages to display. Does anyone know if it's possible to trigger knockout validation without actually changing…
CBlack
  • 683
  • 1
  • 5
  • 9
17
votes
5 answers

Clear error on Knockout-Validation

I have a page setup with Knockout.js and using Knockout-Validation. During the page load I put another plugin on a select box which fires a change, which fires the validation. I need to be able to clear that error using JS so I can start with a…
Clarence Klopfstein
  • 4,682
  • 10
  • 33
  • 47
16
votes
2 answers

Knockout Validation async validators: Is this a bug or am I doing something wrong?

I really like how Eric Barnard's knockout validation lib integrates with observables, allows grouping, & offers custom validator pluggability (including on-the-fly validators). There are a couple of places where it could be more UX…
danludwig
  • 46,965
  • 25
  • 159
  • 237
15
votes
1 answer

Add CSS Class with Knockout Validator

I want to add a CSS Class to a select element in my view, my view model has a property which I've extended using Knockout-Validation: self.selectedRootCause = ko.observable().extend({ required: true }); Then my select is like so:
CallumVass
  • 11,288
  • 26
  • 84
  • 154
14
votes
2 answers

Clearing or resetting a knockout validation validatedObservable?

I have a view model as such: var prop1 = ko.observable().extend{ required: true }, prop2 = ko.observable().extend{ required: true }; var validation = ko.validatedObservable([prop1, prop2]); function resetFields() { prop1(undefined); …
jamiebarrow
  • 2,473
  • 3
  • 30
  • 51
14
votes
1 answer

Knockout Validation ko.validation.group vs ko.validatedObservable

What is the difference in ko.validation.group and ko.validatedObservable? Are there particular situations when I should use one over the other?
Homer
  • 7,594
  • 14
  • 69
  • 109
12
votes
1 answer

Conditional validation not working for anonymous Knockout validation rule

I have following attributes in my viewmodel which use knockout validation,one of them is custom validation to check password match. model.Password = ko.observable() .extend({ required: { message: "Password is required.", …
Cris
  • 12,799
  • 5
  • 35
  • 50
11
votes
1 answer

Problems with knockout-validation custom message template

I've not used Knockout Validation and I'm trying to get a feel for what can be done with it. I'm trying to figure out if it is possible to display an icon rather than an error message to the right of an input tag when there is an error. And, if…
RHarris
  • 10,641
  • 13
  • 59
  • 103
10
votes
1 answer

Knockout Validation: how to validate the fields on button click, not on input change

I'm using the following knockout validation plugin: https://github.com/Knockout-Contrib/Knockout-Validation I want to validate my fields when I click on the "Submit" button, not everytime when I change the input's value. How can I do…
Hristo Eftimov
  • 13,845
  • 13
  • 50
  • 77
1
2 3
34 35