search

Home  >  Q&A  >  body text

Show button when character counter reaches 100

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>

P粉738821035P粉738821035261 days ago540

reply all(1)I'll reply

  • P粉194919082

    P粉1949190822024-04-03 11:57:18

    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!

    
    
       
          
          ΤΙΤΛΟΣ
       
    
       
          
    0/250


    sssccc

    reply
    0
  • Cancelreply