Forms mandatory check : switch to first tab with error

(cherry picked from commit 80e6801db3e7770997e705d087e57b682e8df092)
This commit is contained in:
Pierre Goiffon
2018-10-15 09:10:42 +02:00
parent 452e7cce01
commit 7e4edc6e3a

View File

@@ -154,6 +154,7 @@ function CheckFields(sFormId, bDisplayAlert)
{
if (bDisplayAlert)
{
activateFirstTabWithError(sFormId);
alert(Dict.S('UI:FillAllMandatoryFields'));
}
$('#'+sFormId+' :submit').prop('disable', false);
@@ -166,6 +167,21 @@ function CheckFields(sFormId, bDisplayAlert)
return (oFormErrors['err_'+sFormId] == 0); // If no error, submit the form
}
function activateFirstTabWithError(sFormId) {
var $form = $("#"+sFormId),
$tabsContainer = $form.find(".ui-widget.ui-widget-content"),
$tabs = $tabsContainer.find(".ui-tabs-panel");
$tabs.each(function (index, element) {
var $fieldsWithError = $(element).find(".form_validation");
if ($fieldsWithError.length > 0)
{
$tabsContainer.tabs("option", "active", index);
return;
}
});
}
function ReportFieldValidationStatus(sFieldId, sFormId, bValid, sExplain)
{
if (bValid)