I have written this small script. Can someone help me fix this
I have a problem in mathcing the values of the array against the user input from the textfield.
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.
Thanks in advance
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
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;
}
}
</script>
</head>
<body>
<form name="myForm" action="" onsubmit="return validateForm()" method="post">
Enter your City: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
</body>
</html>