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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -