knockout-validation

How to load knockout.validation with knockout in requirejs

强颜欢笑 提交于 2019-11-28 08:29:55
问题 I am going to define my model in require js and i need knockout and knockout validation plugin in my module and also jquery . define(["knockout","jquery","knockout.validation"], function (ko,$,validation) { // knockout model here with some knockout validation return function SignUpViewModel() { var self = this; self.name = ko.observable(); self.email = ko.observable().extend({ required: true }); self.password = ko.observable().extend({ required: true, minLength: 6 }); self.confirmPassword =

Knockout Validation - How to show error messages

一笑奈何 提交于 2019-11-27 15:51:32
问题 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 the bound answer? 回答1: The solution is to call showAllMessages. If the view model has nested observables, be sure to set ko.validation.configure to use deep grouping because the default value is false. Example: viewModel.save = function() { var

Knockout.js Extending value binding with interceptor

♀尐吖头ヾ 提交于 2019-11-27 11:48:51
问题 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 an interceptor that will format/sanitize/validate input before written/read. ko.bindingHandlers.amountValue = { init: function (element, valueAccessor, allBindingsAccessor) { var underlyingObservable = valueAccessor(); var interceptor = ko

Knockout validation

房东的猫 提交于 2019-11-27 11:26:31
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. Cohen Have a look at Knockout-Validation which cleanly setups and uses what's described in the knockout documentation . Under: Live Example 1: Forcing input to be numeric You can see it live in Fiddle UPDATE : the fiddle has been updated to use the latest KO 2.0.3 and ko.validation 1.0.2 using the cloudfare CDN urls To setup ko.validation: ko.validation

Knockout validation

亡梦爱人 提交于 2019-11-26 15:34:21
问题 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. 回答1: Have a look at Knockout-Validation which cleanly setups and uses what's described in the knockout documentation. Under: Live Example 1: Forcing input to be numeric You can see it live in Fiddle UPDATE : the fiddle has been updated to use the