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

@@ -497,6 +497,11 @@ $('#save-add-recipe-button').on('click', function(e)
{
e.preventDefault();
if (!Grocy.FrontendHelpers.ValidateForm("add-recipe-form", true))
{
return;
}
if ($(".combobox-menu-visible").length)
{
return;
@@ -543,6 +548,11 @@ $('#save-add-note-button').on('click', function(e)
{
e.preventDefault();
if (!Grocy.FrontendHelpers.ValidateForm("add-note-form", true))
{
return;
}
if ($(".combobox-menu-visible").length)
{
return;
@@ -591,6 +601,11 @@ $('#save-add-product-button').on('click', function(e)
{
e.preventDefault();
if (!Grocy.FrontendHelpers.ValidateForm("add-product-form", true))
{
return;
}
if ($(".combobox-menu-visible").length)
{
return;
@@ -645,6 +660,11 @@ $('#save-copy-day-button').on('click', function(e)
{
e.preventDefault();
if (!Grocy.FrontendHelpers.ValidateForm("copy-day-form", true))
{
return;
}
if (document.getElementById("copy-day-form").checkValidity() === false) //There is at least one validation error
{
return false;
@@ -727,9 +747,9 @@ $('#add-product-form input').keydown(function(event)
$(document).on("keydown", "#servings", function(e)
{
if (event.keyCode === 13) //Enter
if (e.keyCode === 13) //Enter
{
event.preventDefault();
e.preventDefault();
if (document.getElementById("add-recipe-form").checkValidity() === false) //There is at least one validation error
{