Show button when character counter reaches 100
P粉738821035
P粉738821035 2024-04-02 18:03:39
0
1
403

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粉738821035
P粉738821035

reply all(1)
P粉194919082

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!