Trying to make a quiz page, I need to show a "submit" button after writing a minimum number of characters in the text area. Here's what I tried but couldn't get it to work.
<textarea name="tweet" id="textbox" rows="13" cols="70" placeholder="" maxlength="250"></textarea><br> <span id="char_count">0/250</span> <script> let textArea = document.getElementById("textbox"); let characterCounter = document.getElementById("char_count"); const minNumOfChars = 0; const maxNumOfChars = 250; var text = document.getElementById("buton"); const countCharacters = () => { let numOfEnteredChars = textArea.value.length; let counter = minNumOfChars + numOfEnteredChars; characterCounter.textContent = counter + "/250"; }; textArea.addEventListener("input", countCharacters); if (counter > 100 ) { text.style.display = "block"; } else { } </script> <br><br><br> <div> <button class="NextStep" id="buton" style="display:none" onclick="NextStep()">Finalizare Curs</button> </div> <script> function NextStep() { location.href =("Cursuri.html") } </script>
Your code has all the necessary parts to work, but you've restructured it like a Picasso painting! A little cut-copy-paste in the right places and you're good to go!