Skip to content

Commit 9088595

Browse files
committed
add restrict to year and month
1 parent 7fd6482 commit 9088595

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/js/popup.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ import { getCurrentYearMonth, downloadICS } from "./utils.js";
33
function initializeInputs() {
44
const { year, month } = getCurrentYearMonth();
55
document.getElementById("yearInput").value = year;
6+
// set year max to year + 1
7+
document.getElementById("yearInput").max = year + 1;
68
document.getElementById("monthInput").value = month;
79
}
810

911
async function fetchCalendarData(sesskey) {
1012
const year = parseInt(document.getElementById("yearInput").value);
1113
const month = parseInt(document.getElementById("monthInput").value);
14+
if (month < 1 || month > 12) {
15+
console.error("Invalid month value:", month);
16+
return;
17+
}
1218
// day is dont care
1319
const day = 1;
1420

src/popup.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ <h1 class="text-xl font-bold">Moodle Calendar</h1>
1111
<input
1212
type="number"
1313
id="yearInput"
14+
min="1992"
1415
class="w-20 px-2 py-1 text-center border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-violet-500 focus:border-violet-500"
1516
placeholder=""
1617
/>
1718
<span class="text-gray-700"></span>
1819
<input
1920
type="number"
2021
id="monthInput"
22+
min="1"
23+
max="12"
2124
class="w-16 px-2 py-1 text-center border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-violet-500 focus:border-violet-500"
2225
placeholder=""
2326
/>

0 commit comments

Comments
 (0)