I have a form which uses a kendo-ui numericTextBox
@Html.LabelFor(p => p.Cost)
@Html.TextBoxFor(p => p.Cost, new { @autocomplete = "off" })
I bind it, then, to make it work with jquery validate plugin, i set the following settings:
$("#Cost").kendoNumericTextBox({
format: "c",
min: 0,
decimals: 2
});
$.validator.setDefaults({
ignore: [],
highlight: function (element, errorClass) {
element = $(element);
if (element.hasClass("k-input")) {
element.closest(".k-widget").addClass(errorClass);
} else {
element.addClass(errorClass);
}
},
unhighlight: function (element, errorClass) {
element = $(element);
if (element.hasClass("k-input")) {
element.closest(".k-widget").removeClass(errorClass);
} else {
element.removeClass(errorClass);
}
}
});
When i try to submit the form and Cost
input is invalid, it adds the errorClass properly (on .k-widget
wrapper).
The problem is that, if i press the submit button again, then the kendo-ui
element simply disappears (with style="display: none;"
).
I don't know what is triggering this. I've seen that if i change the errorClass to something else other than input-validation-error
, then the kendo-ui
widget remains visible.
This issue happens only with kendo-ui
controls, not also with standard html inputs.
I am doing something wrong?