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

153
Visualizações
Function not recognized by Javascript

I've been messing around with Javascript recently and I'm still a beginner. I've been trying to build a simple program which finds a specified string inside the text entered into the text field using regular expressions, but for some reason when I click the "Find" button it gives me the following error:

Uncaught TypeError: find is not a function
    onclick http://192.168.178.20:62126/JavaScript/Findy/index.html:1
index.html:1:1

Here's my code:

<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Findy</title>
    <link rel="stylesheet" href="style.css">
  </head>

  <body>
    <script src="script.js"></script>
    <form action="">
      <input type="text" id="toFind" placeholder="What do you wanna find?">
      <input type="button" id="find" onclick="find()" value="Find"></input>
      <textarea name="textToSearch" id="textToSearch" cols="30" rows="10" placeholder="Enter your text"></textarea>
    </form>
  </body>

</html>
function find() {
  var text=document.getElementById("textToSearch").value;

  var word=document.getElementById(toFind).value;
  var myRegex=/word/;

  console.log(text.match(myRegex));
}

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

0

You need to add a <script> tag below where the find() function is called.

Second solution is to add async attribute to <script> tag

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