From 644c8fdec33271c44065717167aa2dc53c894b12 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Fri, 26 Nov 2021 14:05:06 -0700 Subject: [PATCH] Add check validity function for add season page --- public/scripts/manage/season.js | 14 ++++++++++++++ views/manage/addseason.pug | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/public/scripts/manage/season.js b/public/scripts/manage/season.js index e69de29..82d0204 100644 --- a/public/scripts/manage/season.js +++ b/public/scripts/manage/season.js @@ -0,0 +1,14 @@ +const seasonTextbox = document.getElementById('season-textbox'); +const submitButton = document.getElementById('submit-button'); + +async function checkDataValidity() { + let dataIsValid = true; + + if(seasonTextbox.value == "") dataIsValid = false; + + submitButton.disabled = !dataIsValid; +} +checkDataValidity(); + +seasonTextbox.addEventListener('keyup', checkDataValidity); +seasonTextbox.addEventListener('change', checkDataValidity); diff --git a/views/manage/addseason.pug b/views/manage/addseason.pug index 4050cb2..27783b5 100644 --- a/views/manage/addseason.pug +++ b/views/manage/addseason.pug @@ -9,9 +9,9 @@ block content span(class='form-section') label Ending year span(class='form-section-input') - input(type="number", name="year", value=currentYear) + input#season-textbox(type="number", name="year", value=currentYear) span(class='form-section') - button#submit-button(type="submit") Submit + button#submit-button(type="submit" disabled) Submit block scripts script(src='/scripts/manage/season.js' type="module") \ No newline at end of file