-
Notifications
You must be signed in to change notification settings - Fork 0
/
Input.js
29 lines (29 loc) · 1.16 KB
/
Input.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
let inputs = document.querySelectorAll(".coordinate");
inputs.forEach(function (temp) {
addEventListener("change", function () {
const input = temp;
let value = parseInt(input.value);
if (!isNaN(value) && value >= 1 && value <= 8) {
$(temp).removeClass("is-invalid");
let startX = document.getElementById("startX");
let startY = document.getElementById("startY");
let endX = document.getElementById("endX");
let endY = document.getElementById("endY");
if (!($(startX).hasClass("is-invalid") ||
$(startY).hasClass("is-invalid") ||
$(endX).hasClass("is-invalid") ||
$(endY).hasClass("is-invalid"))) {
start.x = parseInt(startX.value);
start.y = parseInt(startY.value);
end.x = parseInt(endX.value);
end.y = parseInt(endY.value);
}
}
else {
$(temp).addClass("is-invalid");
console.log("input must be a number between 1 and 8, you wrote " + input.value);
return;
}
});
});
//# sourceMappingURL=Input.js.map