kendo validation on tab change
On validation show related tab in asp.net mvc
Problem:
I have a asp.net mvc view. where i have multiple tabs. when user submit form. tab should be activated on which
validation message is occuring.
Solution
on Form Sumbit in jquery function of page submit or button clicked
use
var validator = $("#yourformid").kendoValidator({
validate: function () {
var tabId = $(".k-invalid:first").attr("data-tabid");
var tabLiId = $(".k-invalid:first").attr("data-tabliid");
// alert(tabId + tabLiId);
if (tabId != null && tabLiId != null) {
activateValidTab(tabId, tabLiId);
}
}
}).data("kendoValidator");
this another function that will activate the tab
activateValidTab
function activateValidTab(tabId, tabLiId) {
deActivateTab();
debugger;
$("#" + tabId).addClass('active in');
$("#" + tabLiId).addClass("active");
}
function deActivateTab() {
$("#sim").removeClass("active");
$("#seclims").removeClass("active");
$("#notificationli").removeClass("active");
$("#noteli").removeClass("active");
$("#box_sim").removeClass('active in');
$("#box_Schedule").removeClass('active in');
$("#box_notifications").removeClass('active in');
$("#box_notes").removeClass('active in');
}
Final words: above block of code will diplsay the offend tab, where validation message is occuring
Share This with your friend by choosing any social account