I have a grid that I am using the pop-up editing in. I am using a custom template with drop-downs. The drop-downs have an "Other" option that when selected shows a textbox that you can enter the "Other" details in. This was all in a regular form before I added it to a grid for entry. So I have code for custom validation that would validate these fields if they were showing that worked in a regular form. However, since moving them into the grid pop-up editor, the custom validation is not firing for some reason.
I'm unsure what to do, I have tried to hook the validator up to the grid like so:
$(
"#DeviceGrid"
).kendoValidator({
rules: {
otherrequired:
function
(input) {
if
(input.is(
"[data-val-otherrequired]"
)) {
var
iVal = input.val();
var
pFld = $(
"[name='"
+ input.attr(
"data-val-otherrequired-parentfield"
) +
"_input']"
);
if
(input[0].id ===
"DevicePhoneNum"
) {
if
(pFld.val().toLowerCase().indexOf(
"phone"
) >= 0 && iVal ===
""
) {
return
false
;
}
}
if
(pFld.val() ===
"Other"
&& iVal ===
""
) {
return
false
;
}
}
return
true
;
}
},
messages: {
otherrequired:
function
(input) {
return
input.attr(
"data-val-otherrequired"
);
}
},
validateOnBlur:
true
});
But I'm not sure that this is even the correct way of going about it.
Any insight into this would be appreciated!
Thanks,
Dustin