From fa7fcd50225bb248cddc4c17740f28d293c21752 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 13 May 2021 19:43:49 +0200 Subject: [PATCH] add UI error handler for form with tabs --- assets/js/addons/form.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/assets/js/addons/form.js b/assets/js/addons/form.js index a3e76aa..40bd1c2 100644 --- a/assets/js/addons/form.js +++ b/assets/js/addons/form.js @@ -8,4 +8,26 @@ module.exports = function() { .find('.custom-file-label') .html(inputFile.files[0].name); }); + + $('.nav a').each(function() { + const link = $(this) + const href = link.attr('href') + + if (href.substr(0, 1) !== '#') { + return + } + + console.log(href) + + const tab = $('.tab-pane ' + href) + + if (!tab.length) { + return + } + + if (tab.find('.form-error-message').length) { + link.addClass('border border-danger') + link.click() + } + }) };