knockout.js - Knockout validation message based set in the validation function -


i want set message display in validation function of knockout similar whats going on here: knockout validation plugin custom error message without async.

heres ive tried, no validation message displayed.

this.name = ko.observable().extend({     validation: {         validator: function (val) {             return { isvalid:val === 'a', message: 'the value ' + val + ' not a' };         },         message: 'i dont want default message'     } }); 

jsfiddle

is there way this?

close, validator should returning true/false if rule passed. couldn't message: display value (even setting function had undefined arguments) can inline error message if want display value user.

this.name = ko.observable().extend({     validation: {         validator: function (val) {             if (val !== 'a') {                 this.message = 'the value ' + val + ' not a';                 return false;             }             return true;         }     } }); 

http://jsfiddle.net/gewex/10/


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -