title: How to get value user entered into html text form field passed to javascript function?
body: <p>I'm trying to create my own anti-spam filter by generating random numbers that the user has to enter into a text input form field, if it's correct they proceed to the next page, if not it displays an error that the number entered is incorrect.</p>
  
  <p>I have the following code for my html form:</p>
  
  <pre><code> &lt;form name="input" action="nextpage.html" onSubmit="return checkUserInput()" method="get"&gt;
   Number: 
  
   &lt;input type="text" name="user" /&gt;
   &lt;input type="submit" value="Submit" /&gt;
  
   &lt;/form&gt;
  </code></pre>
  
  <p>The checkUserInput() is a javascript function which will take the user's input, compare it to the random number that was displayed to make sure they're the same, then return true, or false if the two numbers are not the same.</p>
  
  <p>How do I get the input that the user entered into the text field form and pass it to the checkUserInput() function. I was thinking it would be "return checkUserInput(INPUT)" but I'm not sure how to properly pass the user's input to the function.</p>
  
  <p>A secondary issue I have is I'd like the page to refresh with a different random number and an error message to be displayed if the user clicks "Submit" when the numbers aren't the same. Right now the only action that exists is: action="nextpage.html" but I want an option for when checkUserInput() returns false. Is there a way to have two different actions based on whether checkUserInput() returns true or false?</p>
  
  <p>Thanks,
  Joe</p>
  
  <p>Here's also my checkUserInput() function:</p>
  
  <pre><code> var whatevertheyentered;
  
   function checkUserInput(whatevertheyentered){
  
   if(whatevertheyentered == randomnumber){
        return true;
   }
   else {
        return false;
   }
  
   }
  </code></pre>