mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-20 00:58:48 +02:00
Forms mandatory check : switch to first tab with error
(cherry picked from commit 80e6801db3e7770997e705d087e57b682e8df092)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user