mirror of
https://github.com/grocy/grocy.git
synced 2025-08-17 19:16:37 +00:00
Improved form validation handling (closes #1836)
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user