Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
How do you check if user typed the specific word inside a textarea?

How do you check if user typed the specific text inside the textarea tag? Here is an example

 </head>
 <body>
            
            <textarea>
                            
            </textarea>
            <div class="box">
                            
            </div>
            <script>
                            (this is just example)
                            
                            if = user typed inside textarea this =("display (hi)")
                            do = build element inside .box the user typed inside the () of the text "display" 
            </script>

I really don't know how to do it i try to search it but none appeared and if you're confused with code it just glitched

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

With the JS string function includesyou can archive this.

let block = false;
const box = document.querySelector('.box');

  function check(e) {
    const match = e.value.includes("hi");
    if (match && block === false) {
    box.innerHTML = 'Hello again'
    block = true;
  }  
}
<textarea onkeyup="check(this)"></textarea>
<div class="box"></div>

about 4 years ago · Juan Pablo Isaza Relatório

0

I hope it will give you idea. If use type any text and includes hi in textarea. It's will show all text in box container.

let textarea = document.querySelector("textarea");
let box = document.querySelector('.box');

textarea.addEventListener('keyup', (e) => {
  if (e.target.value.includes("hi")){
    box.innerHTML = "";
    box.append(`${e.target.value}`);
  }
})
<textarea></textarea>
<div class="box"></div>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda