title: onsubmit function is not defined
body: <p>Why is it saying that I have not defined my function? Is it because I have placed my function inside a document ready function? - Maybe I have to mention that I want to use this function to prevent submitting if my statement is not true.</p>
  
  <p>my form tag in html:</p>
  
  <pre><code>&lt;form class="text-left" method="post" action="" onsubmit="return myFunction();"&gt;
  </code></pre>
  
  <p>below is script(this script is in my head section) :</p>
  
  <pre><code>$( document ).ready(function() {
  
      //the number generators and sum of the two numbers
      var numberOne = Math.floor((Math.random() * 10) + 1); 
      var numberTwo = Math.floor((Math.random() * 10) + 1);
      var sum = numberOne + numberTwo;
  
      //write the math question to the div
      document.getElementById("captchaOutput").innerHTML = numberOne+ " og " +numberTwo;
      //alert(sum);
  
      function myFunction(){
          var humanInput = $('#captchaInput').val();
  
          if(humanInput == sum){
  
              $("#captcha_service_err").css("display", "inline")
              $("#captchaInput").css("border-color", "red");
               return false;
          }
               $("#captcha_service_err").css("display", "none")
          $("#captchaInput").css("border-color", "");
          return true;       
      }  
  });
  </code></pre>