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
10
votes
2 answers

KnockoutJS Validation with dynamic observables

I am using this plugin https://github.com/ericmbarnard/Knockout-Validation and i am trying to validate an object that is loaded dynamically. Javascript: function VM() { var self = this; // This is a static observable, just to ensure that…
brazorf
  • 1,943
  • 2
  • 32
  • 52
10
votes
3 answers

Knockout validation: Dynamic constraints

I'm using Durandal, which in turn leverages off of Knockout. I want to be able to Change validation lengths dynamically Fiddle The fiddle seems to be behaving slightly different than my "working" solution, but its still not doing what I'm…
Rohan Büchner
  • 5,333
  • 4
  • 62
  • 106
10
votes
1 answer

Knockout Validation disable validation

I have ko.observableArrays with validation on the items. The user can mark a item as deleted. When it is marked as deleted, I need to disable validation on that item. How do you dynamically disable validation? Example:…
Homer
  • 7,594
  • 14
  • 69
  • 109
10
votes
2 answers

Knockout Validation on Array

I am using Knockout Validation to validate a field in an array. It will display the error message, but I cannot get isValid() or ko.validation.group() to work. I need one of these to handle the submit. errors = ko.validation.group(contactList(),…
miked
  • 165
  • 2
  • 7
10
votes
2 answers

Can I manually add error messages in knockout-validation?

I'm using knockout.js and knockout-validation with MVC 4. I can perform client side validation fine with knockout-validation. However I need to ensure that any viewmodels posted to my controller are valid. Therefore I manually validate my view…
handles
  • 7,639
  • 17
  • 63
  • 85
9
votes
1 answer

Knockout Validation - How to show a single error message

I check my view model on submit for validation as described here on SO, actually. My form has a "Save Progress" action in addition to the "Submit" action. It submits to the server in much the same way, but has fewer required fields. I would like…
Brad
  • 229
  • 2
  • 9
9
votes
1 answer

knockout validation error message span

I am using knockout validation plugin and its working fine but i have a little problem , I want to make the validation span a little but more prominent by using css , and i only want to insert the validation span just before the input element ,…
Ancient
  • 3,007
  • 14
  • 55
  • 104
8
votes
1 answer

Customize error message and placement

Currently the Knockout-Validation plugin automatically add this HTML element to my web page: This field is required. I want to change the "This field is required." text. I want to change the placement of the…
Mr.Wang from Next Door
  • 13,670
  • 12
  • 64
  • 97
8
votes
1 answer

How to add a custom message to a pattern validation in ko validation

Let's say I have: self.UserName = ko.observable("").extend({ required: true }).extend({ pattern: '[\S]' }); I'm trying to do something like (I've tried a few variations): self.UserName = ko.observable("").extend({ required: true }).extend({…
Alex KeySmith
  • 16,657
  • 11
  • 74
  • 152
8
votes
1 answer

knockout-validation plugin, get isValid from specific property

Is is possible to see if just one property is valid in the knockout-validation plugin? I could not see any reference to it in the documentation, only the ability to see if the whole model is valid. For example I wish a computed observable to have a…
Alex KeySmith
  • 16,657
  • 11
  • 74
  • 152
8
votes
1 answer

Knockout.js Extending value binding with interceptor

This seems to be a common approach to sanitizing/validating/formatting data with knockout when binding to an input field, it creates a reusable custom binding that uses a computed observable. It basically extends the default value binding to include…
wired_in
  • 2,593
  • 3
  • 25
  • 32
8
votes
2 answers

How to validate an array?

I am trying to use knockout validation lib to validate an array of objects. It is not straightforward to me how to form a validation group for an array of observables. The only way I managed to make it work is like this (JSFIDDLE included): var Note…
Dziamid
  • 11,225
  • 12
  • 69
  • 104
7
votes
2 answers

Knockout Custom Validation with an observable parameter

I have a situation where I need to validate the max amount of a field in my view model. However the max amount has to be variable and is calculated depending on a UI item selected outside of this model. I have attempted to include the observable as…
Stokedout
  • 11,003
  • 5
  • 24
  • 30
7
votes
6 answers

How to tie together ko.validation errors with related viewmodel field names

I'm using Knockout.Validation and I'd like to be able to display an error summary where each line displays the error message (obviously!) and also the field name on the view model related to it, e.g. Age - please enter a number Date of birth -…
philicomus
  • 133
  • 1
  • 9
7
votes
2 answers

Knockout-JS Multi-Step Form with Validation

Looking for a sanity check here. I've recently started learning knockout, and have been instructed to convert an existing multi-step form. The basic idea is to validate each step before allowing the user to continue. There are also certain…
lyma
  • 341
  • 3
  • 11
1
2
3
34 35