title: Validating textfield input from javascript array
body: <p>I have written this small script. Can someone help me fix this</p>
  
  <p>I have a problem in mathcing the values of the array against the user input from the textfield.</p>
  
  <p>I am not sure, whether I need to use a for loop, but the logic seems to be very simple to achieve without for loops.</p>
  
  <p>Thanks in advance</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
  
  var zone1 = new Array("london", "manchester", "spain", "paris");
  var zone2 = new Array("newyork", "toronto", "los angeles", "vancouver");
  var zone3 = new Array("delhi", "seoul", "moscow", "dhaka");
  
  function validateForm()
  {
  var x=document.forms["myForm"]["fname"].value;
  
   if (x==zone1)
    {
    alert("You are in Europe");
    return false;
    }
  
    else if (x==zone2)
    {
    alert("You are in North America");
    return false;
    }
  
    else if (x==zone3)
    {
    alert("You are in Asia");
    return false;
    }
  
    else{
        alert("try again");
        return false;
  
    }
  
  
  
  
  }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form name="myForm" action="" onsubmit="return validateForm()" method="post"&gt;
  Enter your City: &lt;input type="text" name="fname"&gt;
  &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>