From: Moritz Bunkus Date: Thu, 26 Jan 2017 09:18:52 +0000 (+0100) Subject: kivi.js: Funktion zur Prüfung, ob mindestens eine Checkbox gecheckt ist X-Git-Tag: release-3.5.4~1638 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2354f07df49eba13d18601fc97e0cb83fa34d561;p=kivitendo-erp.git kivi.js: Funktion zur Prüfung, ob mindestens eine Checkbox gecheckt ist Kann benutzt werden, um Prüfungen vor Submits zu realisieren. --- diff --git a/js/kivi.js b/js/kivi.js index 27077575d..daf360b23 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -459,6 +459,21 @@ namespace("kivi", function(ns) { if (!found) console.log('No duplicate IDs found :)'); }; + + // Verifies that at least one checkbox matching the + // "checkbox_selector" is actually checked. If not, an error message + // is shown, and false is returned. Otherwise (at least one of them + // is checked) nothing is shown and true returned. + // + // Can be used in checks when clicking buttons. + ns.check_if_entries_selected = function(checkbox_selector) { + if ($(checkbox_selector + ':checked').length > 0) + return true; + + alert(kivi.t8('No entries have been selected.')); + + return false; + }; }); kivi = namespace('kivi');