Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda