1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-23 01:20:11 +00:00

disable generate button if duration is zero

This commit is contained in:
Harvey Tindall 2020-08-16 14:05:16 +01:00
parent fd766e7b1a
commit bd8af153a9
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2

View File

@ -549,6 +549,7 @@ document.getElementById('loginForm').onsubmit = function() {
let minutes = document.getElementById('minutes'); let minutes = document.getElementById('minutes');
addOptions(59, minutes); addOptions(59, minutes);
minutes.selected = "30"; minutes.selected = "30";
checkDuration();
loginModal.hide(); loginModal.hide();
} }
} }
@ -958,3 +959,17 @@ document.getElementById('settingsSave').onclick = function() {
} }
} }
// Diable 'Generate' button if days, hours, minutes are all zero
function checkDuration() {
let boxVals = [document.getElementById("days").value, document.getElementById("hours").value, document.getElementById("minutes").value];
let submit = document.getElementById("generateSubmit");
if (boxVals[0] != 0 || boxVals[1] != 0 || boxVals[2] != 0) {
submit.disabled = false;
} else if (boxVals[0] == 0 && boxVals[1] == 0 && boxVals[2] == 0) {
submit.disabled = true;
}
}
for (i of ["days", "hours", "minutes"]) {
document.getElementById(i).addEventListener("change", checkDuration);
}