Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!