I am looking to have a validation message only be populated when needed. So I have an observable object with 3 fields: Value, IsValid, and Message. IsValid is dependent on Value, and Message is dependent on IsValid.
http://jsfiddle.net/GExfL/
It doesn't appear that this is allowed, but is there an easy way to design the VM to get something similar?
The closest I've come up with is a utility method that is shared by both IsValid and Message (http://jsfiddle.net/GExfL/1/), but it seems a little verbose.
http://jsfiddle.net/GExfL/
var
viewModel = kendo.observable({
OrderNumber: {
Value:
''
,
IsValid:
function
(){
return
(
this
.get(
'Value'
).length >= 8);
},
Message:
function
(){
if
(
this
.get(
'IsValid'
)){
return
''
;
}
else
{
return
'Text length must be at least 8 characters.'
;
}
}
}
});
It doesn't appear that this is allowed, but is there an easy way to design the VM to get something similar?
The closest I've come up with is a utility method that is shared by both IsValid and Message (http://jsfiddle.net/GExfL/1/), but it seems a little verbose.