Tabs: Do not hide HTMl5 validation

This commit is contained in:
Raphael Michel
2019-07-30 14:38:16 +02:00
parent b5fb48a55f
commit 35ae7e4968

View File

@@ -9,6 +9,7 @@ $(function () {
var i = 0;
var preselect = null;
var validity_error = false;
$form.find("fieldset").each(function () {
var $fieldset = $(this);
var tid = "tab-" + j + "-" + i;
@@ -25,6 +26,16 @@ $(function () {
preselect = i;
}
}
$fieldset.find("input, select, textarea").on("invalid", function () {
if ($tablink.find(".fa-warning").length === 0) {
$tablink.append(" ");
$tablink.append($("<span>").addClass("fa fa-warning text-danger"));
if (!validity_error) {
validity_error = true;
$tablink.click();
}
}
});
$fieldset.find("legend").remove();
$fieldset.addClass("tab-pane").attr("id", tid);
if (location.hash && ($fieldset.find(location.hash).length || location.hash === "#" + tid + "-open") && preselect === null) {
@@ -36,6 +47,9 @@ $(function () {
$tabs.find("a").on('shown.bs.tab', function (e) {
history.replaceState(null, null, e.target.getAttribute("href") + "-open");
});
$form.closest("form").on("submit", function () {
validity_error = false;
});
j++;
});
});