diff --git a/public/viewjs/barcodescannertesting.js b/public/viewjs/barcodescannertesting.js index bf630cbf..9b08d0a4 100644 --- a/public/viewjs/barcodescannertesting.js +++ b/public/viewjs/barcodescannertesting.js @@ -8,7 +8,7 @@ $("#scanned_barcode").on("blur", function(e) $("#scanned_barcode").keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); OnBarcodeScanned($("#scanned_barcode").val()); diff --git a/public/viewjs/batteryform.js b/public/viewjs/batteryform.js index e3f7fdf5..7552f7ff 100644 --- a/public/viewjs/batteryform.js +++ b/public/viewjs/batteryform.js @@ -73,11 +73,11 @@ $('#battery-form input').keyup(function(event) $('#battery-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('battery-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('battery-form')) { return false; } diff --git a/public/viewjs/batterytracking.js b/public/viewjs/batterytracking.js index 526349ff..843cb8f6 100644 --- a/public/viewjs/batterytracking.js +++ b/public/viewjs/batterytracking.js @@ -87,11 +87,11 @@ $('#batterytracking-form input').keyup(function(event) $('#batterytracking-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('batterytracking-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('batterytracking-form')) { return false; } diff --git a/public/viewjs/choreform.js b/public/viewjs/choreform.js index fce5e152..151045fe 100644 --- a/public/viewjs/choreform.js +++ b/public/viewjs/choreform.js @@ -86,11 +86,11 @@ $('#chore-form input').keyup(function(event) $('#chore-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('chore-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('chore-form')) { return false; } diff --git a/public/viewjs/choretracking.js b/public/viewjs/choretracking.js index 9d7f6b1b..84f90ddb 100644 --- a/public/viewjs/choretracking.js +++ b/public/viewjs/choretracking.js @@ -123,11 +123,11 @@ $('#choretracking-form input').keyup(function(event) $('#choretracking-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('choretracking-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('choretracking-form')) { return false; } diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js index 1893597b..15cb7699 100644 --- a/public/viewjs/consume.js +++ b/public/viewjs/consume.js @@ -506,11 +506,11 @@ $('#consume-form select').change(function(event) $('#consume-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('consume-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('consume-form')) { return false; } @@ -707,8 +707,7 @@ function ScanModeSubmit(singleUnit = true) $(".input-group-productamountpicker").trigger("change"); } - Grocy.FrontendHelpers.ValidateForm("consume-form"); - if (document.getElementById("consume-form").checkValidity() === true) + if (Grocy.FrontendHelpers.ValidateForm('consume-form')) { $('#save-consume-button').click(); } diff --git a/public/viewjs/equipmentform.js b/public/viewjs/equipmentform.js index 46822a24..02ba150e 100644 --- a/public/viewjs/equipmentform.js +++ b/public/viewjs/equipmentform.js @@ -119,11 +119,11 @@ $('#equipment-form input').keyup(function(event) $('#equipment-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('equipment-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('equipment-form')) { return false; } diff --git a/public/viewjs/inventory.js b/public/viewjs/inventory.js index 306e4d69..fbf158c7 100644 --- a/public/viewjs/inventory.js +++ b/public/viewjs/inventory.js @@ -339,11 +339,11 @@ $('#inventory-form input').keyup(function(event) $('#inventory-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('inventory-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('inventory-form')) { return false; } diff --git a/public/viewjs/locationform.js b/public/viewjs/locationform.js index 98fc54af..9a4e48a1 100644 --- a/public/viewjs/locationform.js +++ b/public/viewjs/locationform.js @@ -73,11 +73,11 @@ $('#location-form input').keyup(function(event) $('#location-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('location-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('location-form')) { return false; } diff --git a/public/viewjs/mealplan.js b/public/viewjs/mealplan.js index fd8bea51..9f4be9ea 100644 --- a/public/viewjs/mealplan.js +++ b/public/viewjs/mealplan.js @@ -507,7 +507,7 @@ $('#save-add-recipe-button').on('click', function(e) return; } - if (document.getElementById("add-recipe-form").checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('add-recipe-form')) { return false; } @@ -558,7 +558,7 @@ $('#save-add-note-button').on('click', function(e) return; } - if (document.getElementById("add-note-form").checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('add-note-form')) { return false; } @@ -611,7 +611,7 @@ $('#save-add-product-button').on('click', function(e) return; } - if (document.getElementById("add-product-form").checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('add-product-form')) { return false; } @@ -665,7 +665,7 @@ $('#save-copy-day-button').on('click', function(e) return; } - if (document.getElementById("copy-day-form").checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('copy-day-form')) { return false; } @@ -713,11 +713,11 @@ $('#save-copy-day-button').on('click', function(e) $('#add-recipe-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById("add-recipe-form").checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('add-recipe-form')) { return false; } @@ -730,11 +730,11 @@ $('#add-recipe-form input').keydown(function(event) $('#add-product-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById("add-product-form").checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('add-product-form')) { return false; } @@ -747,11 +747,11 @@ $('#add-product-form input').keydown(function(event) $(document).on("keydown", "#servings", function(e) { - if (e.keyCode === 13) //Enter + if (e.keyCode === 13) // Enter { e.preventDefault(); - if (document.getElementById("add-recipe-form").checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('add-recipe-form')) { return false; } diff --git a/public/viewjs/mealplansectionform.js b/public/viewjs/mealplansectionform.js index ec14e8af..4f8661a3 100644 --- a/public/viewjs/mealplansectionform.js +++ b/public/viewjs/mealplansectionform.js @@ -61,11 +61,11 @@ $('#mealplansection-form input').keyup(function(event) $('#mealplansection-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('mealplansection-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('mealplansection-form')) { return false; } diff --git a/public/viewjs/productbarcodeform.js b/public/viewjs/productbarcodeform.js index e1b3f6f4..042db704 100644 --- a/public/viewjs/productbarcodeform.js +++ b/public/viewjs/productbarcodeform.js @@ -72,11 +72,11 @@ $('#display_amount').on('keyup', function(e) $('#barcode-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('barcode-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('barcode-form')) { return false; } diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index 6f2b4967..f412b7c4 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -217,19 +217,15 @@ $('#product-form input').keyup(function(event) $(".input-group-qu").trigger("change"); $("#product-form select").trigger("select"); - if (document.getElementById('product-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('product-form')) { $("#qu-conversion-add-button").addClass("disabled"); + $("#barcode-add-button").addClass("disabled"); } else { $("#qu-conversion-add-button").removeClass("disabled"); } - - if (document.getElementById('product-form').checkValidity() === false) //There is at least one validation error - { - $("#barcode-add-button").addClass("disabled"); - } }); $('#location_id').change(function(event) @@ -239,11 +235,11 @@ $('#location_id').change(function(event) $('#product-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('product-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('product-form')) { return false; } diff --git a/public/viewjs/productgroupform.js b/public/viewjs/productgroupform.js index e6d54352..492d0118 100644 --- a/public/viewjs/productgroupform.js +++ b/public/viewjs/productgroupform.js @@ -59,11 +59,11 @@ $('#product-group-form input').keyup(function(event) $('#product-group-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('product-group-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('product-group-form')) { return false; } diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index 71b9235f..775205ad 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -342,7 +342,7 @@ if (Grocy.Components.ProductPicker !== undefined) $("#display_amount").focus(); Grocy.FrontendHelpers.ValidateForm('purchase-form'); - if (GetUriParam("flow") === "shoppinglistitemtostock" && BoolVal(Grocy.UserSettings.shopping_list_to_stock_workflow_auto_submit_when_prefilled) && document.getElementById("purchase-form").checkValidity() === true) + if (GetUriParam("flow") === "shoppinglistitemtostock" && BoolVal(Grocy.UserSettings.shopping_list_to_stock_workflow_auto_submit_when_prefilled) && Grocy.FrontendHelpers.ValidateForm("purchase-form")) { $("#save-purchase-button").click(); } @@ -515,11 +515,11 @@ $('#purchase-form input').keyup(function(event) $('#purchase-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('purchase-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('purchase-form')) { return false; } @@ -701,7 +701,7 @@ function ScanModeSubmit(singleUnit = true) } Grocy.FrontendHelpers.ValidateForm("purchase-form"); - if (document.getElementById("purchase-form").checkValidity() === true) + if (Grocy.FrontendHelpers.ValidateForm('purchase-form')) { $('#save-purchase-button').click(); } diff --git a/public/viewjs/quantityunitconversionform.js b/public/viewjs/quantityunitconversionform.js index 85f1f847..10edc375 100644 --- a/public/viewjs/quantityunitconversionform.js +++ b/public/viewjs/quantityunitconversionform.js @@ -137,11 +137,11 @@ $('#quconversion-form input').keyup(function(event) $('#quconversion-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('quconversion-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('quconversion-form')) { return false; } diff --git a/public/viewjs/quantityunitform.js b/public/viewjs/quantityunitform.js index 14db0978..5acba767 100644 --- a/public/viewjs/quantityunitform.js +++ b/public/viewjs/quantityunitform.js @@ -110,7 +110,7 @@ $('#quantityunit-form input').keyup(function(event) $("#qu-conversion-headline-info").text(""); } - if (document.getElementById('quantityunit-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('quantityunit-form')) { $("#qu-conversion-add-button").addClass("disabled"); } @@ -124,11 +124,11 @@ $('#quantityunit-form input').keyup(function(event) $('#quantityunit-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('quantityunit-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('quantityunit-form')) { return false; } diff --git a/public/viewjs/recipeform.js b/public/viewjs/recipeform.js index 33f057ec..2c128404 100644 --- a/public/viewjs/recipeform.js +++ b/public/viewjs/recipeform.js @@ -116,11 +116,11 @@ $('#recipe-form input').keyup(function(event) $('#recipe-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('recipe-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('recipe-form')) { return false; } @@ -308,7 +308,7 @@ $('#save-recipe-include-button').on('click', function(e) if (!Grocy.FrontendHelpers.ValidateForm("recipe-include-form", true)) { - return; + return false; } if ($(".combobox-menu-visible").length) @@ -316,11 +316,6 @@ $('#save-recipe-include-button').on('click', function(e) return; } - if (document.getElementById("recipe-include-form").checkValidity() === false) //There is at least one validation error - { - return false; - } - var nestingId = $("#recipe-include-form").data("recipe-nesting-id"); var editMode = $("#recipe-include-form").data("edit-mode"); diff --git a/public/viewjs/recipeposform.js b/public/viewjs/recipeposform.js index acec2007..316ffe06 100644 --- a/public/viewjs/recipeposform.js +++ b/public/viewjs/recipeposform.js @@ -131,11 +131,11 @@ $('#qu_id').change(function(event) $('#recipe-pos-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('recipe-pos-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('recipe-pos-form')) { return false; } diff --git a/public/viewjs/shoppinglistform.js b/public/viewjs/shoppinglistform.js index 8d7c5915..db58ee69 100644 --- a/public/viewjs/shoppinglistform.js +++ b/public/viewjs/shoppinglistform.js @@ -63,11 +63,11 @@ $('#shopping-list-form input').keyup(function(event) $('#shopping-list-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('shopping-list-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('shopping-list-form')) { return false; } diff --git a/public/viewjs/shoppinglistitemform.js b/public/viewjs/shoppinglistitemform.js index fa444703..db10c28a 100644 --- a/public/viewjs/shoppinglistitemform.js +++ b/public/viewjs/shoppinglistitemform.js @@ -241,11 +241,11 @@ $('#shoppinglist-form input').keyup(function(event) $('#shoppinglist-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('shoppinglist-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('shoppinglist-form')) { return false; } diff --git a/public/viewjs/shoppinglocationform.js b/public/viewjs/shoppinglocationform.js index 16e90208..598f2c67 100644 --- a/public/viewjs/shoppinglocationform.js +++ b/public/viewjs/shoppinglocationform.js @@ -73,11 +73,11 @@ $('#shoppinglocation-form input').keyup(function(event) $('#shoppinglocation-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('shoppinglocation-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('shoppinglocation-form')) { return false; } diff --git a/public/viewjs/stockentryform.js b/public/viewjs/stockentryform.js index e20a8d6f..ba503c36 100644 --- a/public/viewjs/stockentryform.js +++ b/public/viewjs/stockentryform.js @@ -68,11 +68,11 @@ $('#stockentry-form input').keyup(function(event) $('#stockentry-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('stockentry-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('stockentry-form')) { return false; } diff --git a/public/viewjs/taskcategoryform.js b/public/viewjs/taskcategoryform.js index 4ec20607..a28b5c62 100644 --- a/public/viewjs/taskcategoryform.js +++ b/public/viewjs/taskcategoryform.js @@ -73,11 +73,11 @@ $('#task-category-form input').keyup(function(event) $('#task-category-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('task-category-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('task-category-form')) { return false; } diff --git a/public/viewjs/taskform.js b/public/viewjs/taskform.js index 397fb1b3..7ca88741 100644 --- a/public/viewjs/taskform.js +++ b/public/viewjs/taskform.js @@ -93,11 +93,11 @@ $('#task-form input').keyup(function(event) $('#task-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('task-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('task-form')) { return false; } diff --git a/public/viewjs/transfer.js b/public/viewjs/transfer.js index 5e7a5106..f6d35f46 100644 --- a/public/viewjs/transfer.js +++ b/public/viewjs/transfer.js @@ -383,11 +383,11 @@ $('#transfer-form select').change(function(event) $('#transfer-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('transfer-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('transfer-form')) { return false; } diff --git a/public/viewjs/userentityform.js b/public/viewjs/userentityform.js index a02cea61..99edc59b 100644 --- a/public/viewjs/userentityform.js +++ b/public/viewjs/userentityform.js @@ -73,11 +73,11 @@ $('#userentity-form select').change(function(event) $('#userentity-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('userentity-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('userentity-form')) { return false; } diff --git a/public/viewjs/userfieldform.js b/public/viewjs/userfieldform.js index a7b89d38..e4e18ca9 100644 --- a/public/viewjs/userfieldform.js +++ b/public/viewjs/userfieldform.js @@ -77,11 +77,11 @@ $('#userfield-form select').change(function(event) $('#userfield-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('userfield-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('userfield-form')) { return false; } diff --git a/public/viewjs/userform.js b/public/viewjs/userform.js index 87c227a5..39d334b6 100644 --- a/public/viewjs/userform.js +++ b/public/viewjs/userform.js @@ -105,11 +105,11 @@ $('#user-form input').keyup(function(event) $('#user-form input').keydown(function(event) { - if (event.keyCode === 13) //Enter + if (event.keyCode === 13) // Enter { event.preventDefault(); - if (document.getElementById('user-form').checkValidity() === false) //There is at least one validation error + if (!Grocy.FrontendHelpers.ValidateForm('user-form')) { return false; }