diff --git a/public/index.js b/public/index.js index 33efa327ea97df77feb2b0bf1e450c8f59d79654..bbcdffaf86c2ae5300ad4fe925e20b2bb734aeb7 100644 --- a/public/index.js +++ b/public/index.js @@ -43,12 +43,13 @@ function setCharacterLength(characters) { } function calculateReadingTime() { - let isFormValid = validateForm(); - let x = document.getElementById('calculate-time-element'); - x.style.display = "block"; + if (isFormValid()) { + let x = document.getElementById('calculate-time-element'); + x.style.display = "block"; + } } -function validateForm() { +function isFormValid() { let invalidFields = 0; if (inputObj.textChoice === 'manual' && inputObj.text === '') { invalidFields++; @@ -77,7 +78,9 @@ function validateForm() { } else { document.getElementById('readerCategory-validation').style.display = 'none'; } - + + return invalidFields < 1 + } function showFeedbackForm() {