jQuery Validation with Bootstrap Tabs -
i have form multiple bootstrap tabs , inside them multiple input , select fields, required , not.
i using jquery validation plugin validate form. below highlight , unhighlight errors using bootstrap css working fine:
highlight: function(element) { $(element).closest('.input-group').addclass('has-error'); }, unhighlight: function(element) { $(element).closest('.input-group').removeclass('has-error'); },
what need if tab has not validated field, want tab highlight.
i used below code, funny thing code works , highlights tab red colour, , doesn't work.
if($(".tab-content").find("div.tab-pane:has(div.has-error)").length != 0){ $(".tab-content").find("div.tab-pane:has(div.has-error)").each(function(index, tab){ var id = $(tab).attr("id"); $('a[href="#' + id + '"]').tab('show').addclass('bg-danger'); }); } else { $(".nav-tabs li a").each(function(){ if($(this).hasclass('bg-danger')){ $(this).removeclass('bg-danger'); } }); }
what doing wrong , how can highlight tabs if there required field error?
Comments
Post a Comment