From 405e2d9b50eb40e28b0cd1f805042aae9d6512e8 Mon Sep 17 00:00:00 2001 From: Robin McCorkell Date: Tue, 26 Jan 2016 17:25:59 +0000 Subject: [PATCH] Fix validation of inputs that aren't text --- apps/files_external/js/settings.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 2f879e1c85..756804238d 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -59,10 +59,24 @@ function highlightBorder($element, highlight) { return highlight; } +function isInputValid($input) { + var optional = $input.hasClass('optional'); + switch ($input.attr('type')) { + case 'text': + case 'password': + if ($input.val() === '' && !optional) { + return false; + } + break; + } + return true; +} + function highlightInput($input) { - if ($input.attr('type') === 'text' || $input.attr('type') === 'password') { - return highlightBorder($input, - ($input.val() === '' && !$input.hasClass('optional'))); + switch ($input.attr('type')) { + case 'text': + case 'password': + return highlightBorder($input, !isInputValid($input)); } } @@ -952,7 +966,7 @@ MountConfigListView.prototype = _.extend({ if ($input.attr('type') === 'button') { return; } - if ($input.val() === '' && !$input.hasClass('optional')) { + if (!isInputValid($input)) { missingOptions.push(parameter); return; }