title: Checking to see if the input value matches any value within an array before returning true
body: <p>I'm trying to validate a form using javascript. Checking to see if the input value matches any value within an array before returning true.</p>
  
  <p>Here's an example of what I have written so far. Yet this seems to not work.</p>
  
  <pre><code>&lt;script type='text/javascript'&gt;
  
  function checkForm() 
  { 
  
  var agent = document.getElementById('agent').value;
  
  var myArray = new Array() 
    myArray[0] = 'First Agent';
    myArray[1] = 'Second Agent';
    myArray[2] = 'Third Agent';
  
  if (agent != myArray) 
  {
    alert("Invalid Agent");
    return false;
  } 
  
  else 
  {
    return true;
  }
  }
  
  &lt;form&gt;
  &lt;fieldset&gt;
  Agents Name*
  &lt;input type="text" size="20" name="agent" id="agent"&gt;
  &lt;/fieldset&gt;
  &lt;/form&gt;
  </code></pre>