all repos — cameraman @ ac9177ae9453c770241849e2831d3d3611993ebc

check numbers on input
BiRabittoh andronacomarco@gmail.com
Mon, 03 Jun 2024 13:09:44 +0200
commit

ac9177ae9453c770241849e2831d3d3611993ebc

parent

eb9b7cafaf94115452f4ddb35a7269a2045743c3

1 files changed, 2 insertions(+), 2 deletions(-)

jump to
M templates/index.htmltemplates/index.html

@@ -187,7 +187,7 @@ }

} function padNumber(input, n=2) { - return input.toString().padStart(n, '0'); + return Math.max(1, Math.min(input, 12)).toString().padStart(n, '0'); } function createRow(id, name, description, day, month, notify, notified) {

@@ -208,7 +208,7 @@ function createInputFields(id, name, description, day, month, notify, notified, isNew) {

return ` <td><input class="big-input" type="text" value="${name || ''}" id="name-${id}"></td> <td><input class="big-input" type="text" value="${description || ''}" id="description-${id}"></td> - <td class="date-inputs"><input type="number" value="${day || ''}" id="day-${id}" class="small-input" min="1" max="31" onchange="this.value = padNumber(this.value);"> / <input type="number" value="${month || ''}" id="month-${id}" class="small-input" min="1" max="12" onchange="this.value = padNumber(this.value);"></td> + <td class="date-inputs"><input type="number" value="${day || ''}" id="day-${id}" class="small-input" min="1" max="31" onchange="this.value = padNumber(this.value);"> /<input type="number" value="${month || ''}" id="month-${id}" class="small-input" min="1" max="12" onchange="this.value = padNumber(this.value);"></td> <td><input type="checkbox" id="notify-${id}" ${notify ? 'checked' : ''}></td> <td><input type="checkbox" id="notified-${id}" ${notified ? 'checked' : 'disabled'}></td> <td class="actions">