Hi,
I have a custom rule that check to see if a grid has any rows when a certain check is checked. The rule works correctly (that is it prevents submission if it is not met and allows if it is met), but the defined message is never added to the errors collection and therefore not displayed on screen. The other two custom rule / messages work as intended and display correctly.
I am using the Q2 2015 professional version in an MVC 4 web app with bootstrap.
Here is the validator configuration, which is contained within a standard jQuery 'document.ready' function:
01.
jQuery(
"#HAForm"
).kendoValidator({
02.
rules: {
03.
pupilSelected:
function
(input) {
04.
if
(input.is(
"#pupilSelector [type=checkbox]"
)) {
05.
return
jQuery(
"#pupilSelector input:checked"
).length > 0;
06.
}
07.
08.
return
true
;
09.
},
10.
travelOptionSelected:
function
(input) {
11.
if
(input.is(
"#travelOptions [type=checkbox]"
)) {
12.
return
jQuery(
"#travelOptions input:checked"
).length > 0;
13.
}
14.
15.
return
true
;
16.
},
17.
flightsAdded:
function
(input) {
18.
if
(input.is(
"#travelOptions input:checked[value='Flying']"
)) {
19.
return
jQuery(
"#flightGrid"
).data(
"kendoGrid"
).tbody.find(
'>tr'
).length > 0;
20.
}
21.
22.
return
true
;
23.
}
24.
},
25.
messages: {
26.
pupilSelected:
"You must choose at least one pupil."
,
27.
travelOptionSelected:
"You must choose at least one travel option."
,
28.
flightsAdded:
"You must add at least one flight."
29.
},
30.
validate:
function
() {
31.
showErrors(
this
.errors());
32.
}
33.
});
And this is the code that displays the errors on screen:
01.
function
showErrors(errors) {
02.
var
errorsContainer = jQuery(
"#errors"
);
03.
var
html =
""
;
04.
05.
for
(
var
idx = 0; idx < errors.length; idx++) {
06.
html +=
"<li>"
+ errors[idx] +
"</li>"
;
07.
}
08.
09.
errorsContainer.empty().append(jQuery(html));
10.
}
I am at a loss as to why the first two messages display correctly but the 'flightsAdded' message is never displayed even when it is the only rule.
Thanks
Chris