Between two numbers validation in knockout?

216 views Asked by At

I am trying to write a validation which performs like similar to between .

I am having a textbox and i want show error message if he failed to enter anything other than the given range .

ViewModel :

var vm = function viewModel()
{
var self = this;
self.mainamount=ko.observable();
self.amount1=ko.observable(2); // this will be dynamic
self.amount2=ko.observable(100)

self.validation = ko.validatedObservable({
self.mainamount.extend({required:true,number:true,min:self.amount1,max:self.amount2})  
});
}

I tought min and max together acts like between but i'm wrong and i am unable to work it out .

I gave a tought to try something like this

validator:{validation:function(param1,param2,param3){ //logic here },
message:'enter between these ..',
params: // here i am unable to pass multiple paramters 
}

Reference : Click here . In this article at last there is some custom way to do things but i am confused in return statement inside computed .

Any help is appreciated .

0

There are 0 answers