Fix validation of inputs that aren't text

This commit is contained in:
Robin McCorkell 2016-01-26 17:25:59 +00:00
parent ecf2d178b1
commit 405e2d9b50
1 changed files with 18 additions and 4 deletions

View File

@ -59,10 +59,24 @@ function highlightBorder($element, highlight) {
return 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) { function highlightInput($input) {
if ($input.attr('type') === 'text' || $input.attr('type') === 'password') { switch ($input.attr('type')) {
return highlightBorder($input, case 'text':
($input.val() === '' && !$input.hasClass('optional'))); case 'password':
return highlightBorder($input, !isInputValid($input));
} }
} }
@ -952,7 +966,7 @@ MountConfigListView.prototype = _.extend({
if ($input.attr('type') === 'button') { if ($input.attr('type') === 'button') {
return; return;
} }
if ($input.val() === '' && !$input.hasClass('optional')) { if (!isInputValid($input)) {
missingOptions.push(parameter); missingOptions.push(parameter);
return; return;
} }