From 5bd8e465108f3ee386b4716ecc9b85718366e783 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 1 Feb 2017 10:33:29 -0800 Subject: [PATCH] only check if keys are empty, not all fields --- .../resources/web/settings/js/settings.js | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/domain-server/resources/web/settings/js/settings.js b/domain-server/resources/web/settings/js/settings.js index b04d55b9eb..3ed7d02364 100644 --- a/domain-server/resources/web/settings/js/settings.js +++ b/domain-server/resources/web/settings/js/settings.js @@ -908,31 +908,11 @@ function validateInputs() { } _.each(tables, function(table) { - var inputs = $(table).find('tr.' + Settings.NEW_ROW_CLASS + ':not([data-category]) input[data-changed="true"]'); - - var empty = false; - - _.each(inputs, function(input){ - var inputVal = $(input).val(); - - if (inputVal.length === 0) { - empty = true - - markParentRowInvalid(input); - return; - } - }); - - if (empty) { - showErrorMessage("Error", "Empty field(s)"); - inputsValid = false; - return - } - // validate keys specificially for spaces and equality to an existing key var newKeys = $(table).find('tr.' + Settings.NEW_ROW_CLASS + ' td.key'); var keyWithSpaces = false; + var empty = false; var duplicateKey = false; _.each(newKeys, function(keyCell) { @@ -944,6 +924,14 @@ function validateInputs() { return; } + // make sure the key isn't empty + if (keyVal.length === 0) { + empty = true + + markParentRowInvalid(input); + return; + } + // make sure we don't have duplicate keys in the table var otherKeys = $(table).find('td.key').not(keyCell); _.each(otherKeys, function(otherKeyCell) { @@ -971,6 +959,12 @@ function validateInputs() { return } + if (empty) { + showErrorMessage("Error", "Empty field(s)"); + inputsValid = false; + return + } + if (duplicateKey) { showErrorMessage("Error", "Two keys cannot be identical"); inputsValid = false;