title: Validation with javascript from list
body: <p>I'm trying to validate a form filed via javascript. The idea is that the form filed has a set list of accepted values and only these values work. So if the field is black it will alert that the ID is incorrect. If the field has input which is not in the list it will display that ID is incorrect. I have gotten close. I just need a little more direction. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>script type="text/javascript"&gt;
          function validateForm()
          {
              var x=document.forms["dispatch"]["ID1"].value;
              var arr=["CA238", "Pete", "John"];
              if x==(.inArray(inputVal, arr) &gt; -1)
              {
    alert("Correct Dispatcher ID Required");
    return false;
    }
  }
  &lt;/script&gt;
  
  &lt;form id="form_242533" class="appnitro" name="dispatch" onsubmit="return validateForm()" method="post" action="&lt;?php echo $_SERVER["PHP_SELF"]?&gt;"&gt;
  &lt;li id="li_9" &gt;
              &lt;label class="description" for="element_1"&gt;Dispatch ID&lt;/label&gt;
          &lt;div&gt;
              &lt;input id="element_1" name="ID1" class="element text medium" type="text"  value=""/&gt; Put your assigned dispatcher ID
          &lt;/div&gt; 
          &lt;/li&gt;
  
                      &lt;li class="buttons"&gt;
                  &lt;input type="hidden" name="Submit" value="Submit" /&gt;
  
                  &lt;input id="submit" class="button_text" type="submit" name="submit" value="Submit" /&gt;
                  &lt;input type="reset" /&gt;
  
          &lt;/li&gt;
              &lt;/ul&gt;
          &lt;/form&gt;
  </code></pre>