I use the tab of bootstrap
and required
of dataannotations
,
but the following happens, you do not know the fields of the required, when it is not in tab
of it, for example, I am in tab
1, and I conclude, however in 2 fields with required
are not filled, not to know, I'd like it to be tab
where fields with required
were not filled.
I tried this code, both in submit
and with the click of button
, but it did not work:
$('#btnConcluir').click(function () {
$('input:invalid').each(function () {
// Find the tab-pane that this element is inside, and get the id
var $closest = $(this).closest('.tab-pane');
var id = $closest.attr('id');
// Find the link that corresponds to the pane and have it show
$('.nav a[href="#' + id + '"]').tab('show');
// Only want to do it once
return false;
});
});
I tried this here too:
$('#btnConcluir').click(function () {
console.log('entrou');
$(':required:invalid', '#FornecedorNovo').each(function () {
var id = $('.tab-pane').find(':required:invalid').closest('.tab-pane').attr('id');
$('.nav a[href="#' + id + '"]').tab('show');
});
});