Skip to content

Commit e1e9223

Browse files
committed
separate highlight logic from submit logic
1 parent ff174fe commit e1e9223

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

webroot/panel/account.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ function getNewLoginShell() {
272272
}
273273
return $("#customLoginBox").val();
274274
}
275+
275276
function isLoginShellValid(x) {
276277
if (x.trim().length === 0) {
277278
return false;
@@ -282,21 +283,31 @@ function isLoginShellValid(x) {
282283
}
283284
return true;
284285
}
286+
287+
function enableOrDisableCustomLoginBoxHighlight() {
288+
if (
289+
($("#loginSelector").val() == "Custom") &&
290+
!isLoginShellValid($("#customLoginBox").val())
291+
) {
292+
$("#customLoginBox").css("box-shadow", "0 0 0 0.3rem rgba(220, 53, 69, 0.25)");
293+
} else {
294+
$("#customLoginBox").css("box-shadow", "none");
295+
}
296+
}
297+
$("#customLoginBox").on("input", enableOrDisableCustomLoginBoxHighlight);
298+
enableOrDisableCustomLoginBoxHighlight();
299+
285300
function enableOrDisableSubmitLoginShell() {
286-
var submitLoginShell = $("#submitLoginShell");
287301
var newLoginShell = getNewLoginShell();
288302
if (!isLoginShellValid(newLoginShell)) {
289-
submitLoginShell.attr("disabled", true);
290-
$("#customLoginBox").css("box-shadow", "0 0 0 0.3rem rgba(220, 53, 69, 0.25)");
303+
$("#submitLoginShell").attr("disabled", true);
291304
return;
292-
} else {
293-
$("#customLoginBox").css("box-shadow", "none");
294305
}
295306
if (newLoginShell == ldapLoginShell) {
296-
submitLoginShell.attr("disabled", true);
307+
$("#submitLoginShell").attr("disabled", true);
297308
return;
298309
}
299-
submitLoginShell.attr("disabled", false);
310+
$("#submitLoginShell").attr("disabled", false);
300311
}
301312
$("#customLoginBox").on("input", enableOrDisableSubmitLoginShell);
302313
$("#loginSelector").change(enableOrDisableSubmitLoginShell);

0 commit comments

Comments
 (0)