knockout-validation

Knockout Validation validatedObservable group error

≡放荡痞女 提交于 2019-12-13 18:47:41
问题 I have a group of items that I need to validate as a whole. I setup a validatedObservable on the group, but the error message doesn't display. I have a simplified example here. I want each number to be between 0-100 and the sum to be exactly 100. How do I handle this kind of validation? Update: I know in this example I could just make a ko.computed and validate that, but that's not what I need. Example: http://jsfiddle.net/CGuW2/5/ 0-100:<input data-bind="value: num1, valueUpdate:

Knockout Validation on Breeze.js entities

ε祈祈猫儿з 提交于 2019-12-13 07:15:03
问题 I'm trying to get Knockout Validation running on my Breeze.js entities but not having much luck. So currently I'm just trying to get a very basic test working to confirm the approach should work but am stumped as to why this is not even working. Essentially I have something like the following running when the user edits one of my entities in an attempt to register knockout validation on the resulting entity from breeze: dataService.getEntity(selectedRowId()) .then(function(result) {

Move validation from observable to computed

杀马特。学长 韩版系。学妹 提交于 2019-12-13 00:48:15
问题 I have a custom KO extension that formats numbers, this extender wraps the original observable in a computed and return the new reference to the computed. There is a problem, lets say down the chain before the number extender is called someone adds a validation to the observable, then this validation will not work when the computed is exposed by the number extender. Can I somehow move the validation from the observable to the computed? Off course I can make sure that the validation is added

Knockout ViewModel isValid error when using Knockout validation plugin

房东的猫 提交于 2019-12-12 12:19:49
问题 I'm new to using knockout and I'm trying to use the knockout validation plugin along with the mapping plugin. I'm having an issue with the isValid function on the view model object. According to the documentation isValid should return a bool to determine whether any of the observables on the view model are in valid but when I call it I get an error saying that isValid is not a function. However if I call isValid on the observables themselves it works fine. The problem is I'm using the mapping

validation not working in knockout js

邮差的信 提交于 2019-12-12 06:59:13
问题 I am validating an input field for unique parameters for this i am using this code . self.loanterm = ko.observable().extend({ required: true,unique: { collection: self.termValues, externalValue: "" } }); but when i am adding duplicate value it doesn't showing me any message. termValues is an observable array whose values i am adding like this . self.PopulateLoans = ko.computed(function(){ ko.utils.arrayForEach(dummyData, function(item){ self.Terms.push(new Term(item)); self.termValues.push

Is there a way to extend validation on Knockout Validation's validatedObservable?

馋奶兔 提交于 2019-12-12 03:32:30
问题 I need to make sure each observable is valid and also make sure all the observables are valid together. In my simplified example I have a modelNumber and stockNumber that are each required, but together they must also form a valid partNumber. My attempt gives me this error: "Uncaught Error: Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters." What's the problem? https://jsfiddle.net/yekr2ov2/18/ // enable

Validation in knockout js input fields

[亡魂溺海] 提交于 2019-12-11 07:57:19
问题 I created some input fields using KnockoutJS, and now I want to validate them. http://jsfiddle.net/sohimohit/43zkoszu/12/ I tried it using validation plugin but it doesn't work. I added that plugin and used it as mentioned but didn't get the solution. When you click on "add field" a form appears; I want to make the name field required and branch id as numeric. However, when I click on "add fields" it doesn't get added until the form is validated. How can I achieve this? 回答1: You are not doing

How to do validations using knockout js validations?

妖精的绣舞 提交于 2019-12-11 03:33:18
问题 I want to do client side validations using knockout js. for example , I want to validate below element as required, number only and it should not exceed 10 digits? How can we achieve this using knockout js validation ? <input data-bind='value: phone' required digits='true' maxlength='10' /> any thoughts ? 回答1: Take a look at Knockout.validation and use this obsevable extension : phoneNumber.extend({digit: true}).extend({ maxLength: 10 }); See fiddle I hope it hepls. 来源: https://stackoverflow

Why does IE 8 crash with bootstrap, knockout validation and custom binding handler when mouse out of parent?

筅森魡賤 提交于 2019-12-11 03:21:13
问题 Ok.. this is a crazy bug that me and a colleague cannot figure out. Internet Explorer 8 crashes (no console error message). It happens when a knockout observable value is changed using a radio input with a custom binding (data-bind) AND you move out of the parent DOM container. This error CANNOT be reproduced using Internet Explorer 9 in IE 8 Browser Mode - only a true standalone Internet Explorer 8 install will produce this error. One thing that I did notice, is that if the knockout

Knockout Validation - Dont validate input when empty + evaluate when submit

自作多情 提交于 2019-12-10 14:51:48
问题 check this fiddle: http://jsfiddle.net/bhzrw01s/ I was trying to do 2 things: First: Dont validate when the field is empty. I know there is a onlyif option.. but is there something easier? Second: I need something to run the validation when i click on submit (If you test my fiddle, the error messages will pop, but wont apply the errorClass css) Thanks :D css: input.error { color: red; border-color: red; } js: ko.validation.configure({ insertMessages: false, decorateElement: true,