diff --git a/public/index.js b/public/index.js index ca553ccf5d0e338b6f9598ceca2f643263e85a92..3c6b1d273decd3b218832fbbcda4e23d3a6e3f3f 100644 --- a/public/index.js +++ b/public/index.js @@ -12,6 +12,15 @@ let inputObj = { function handleTextRadioClick() { let textChoice = document.querySelector('input[name="text-input-option"]:checked').value; inputObj.textChoice = textChoice; + if (textChoice === 'manual') { + let value = removeSpecialCharacters(inputObj.text); + let characters = value.length; + setCharacterLength(characters); + } else { + let value = document.getElementById("inputTextCharacters").value; + setCharacterLength(value); + } + isFormValid(); toggleElement('character-calculation-wrapper'); toggleElement('manual-character-input'); } @@ -96,6 +105,13 @@ function isFormValid() { document.getElementById('category-validation').style.display = 'none'; } + if ((inputObj.numberOfCharacters < 100 && (inputObj.schoolLevel === '1' || inputObj.schoolLevel === '2'))) { + invalidFields++; + document.getElementById('min-count-validation').style.display = 'block'; + } else { + document.getElementById('min-count-validation').style.display = 'none'; + } + return invalidFields < 1 } @@ -238,7 +254,7 @@ function calculateReadingTime() { } } -// function getFormatted time +// function getFormattedTime // accepts seconds value and returns in hh:mm:ss format function getFormattedTime(totalSeconds) { let hours = Math.floor(totalSeconds / 3600);