Improved form validation handling (closes #1836)

This commit is contained in:
Bernd Bestel
2022-03-26 10:34:00 +01:00
parent 6aae97de73
commit 81b54182de
33 changed files with 180 additions and 17 deletions

View File

@@ -382,7 +382,7 @@ window.FontAwesomeConfig = {
}
Grocy.FrontendHelpers = {};
Grocy.FrontendHelpers.ValidateForm = function(formId)
Grocy.FrontendHelpers.ValidateForm = function(formId, reportValidity = false)
{
var form = document.getElementById(formId);
if (form === null || form === undefined)
@@ -390,17 +390,14 @@ Grocy.FrontendHelpers.ValidateForm = function(formId)
return;
}
if (form.checkValidity() === true)
$(form).addClass('was-validated');
if (reportValidity)
{
$(form).find(':submit').removeClass('disabled');
$(form).find('.keep-disabled').addClass('disabled');
}
else
{
$(form).find(':submit').addClass('disabled');
form.reportValidity();
}
$(form).addClass('was-validated');
return form.checkValidity();
}
Grocy.FrontendHelpers.BeginUiBusy = function(formId = null)