For some reason the enterkey calls the functions but won't populate the next page unless the alert is there.
If I remove the alert the page will only send using the onclick event
If I remove the alert the page will only send using the onclick event
Code:
<script language="javascript">
var ZIPS ="07071/07072";
var ZIPS2 ="07960/07961";
var zipArray = ZIPS.split("/");
var zip2Array = ZIPS2.split("/");
document.onkeypress = processKey;
function processKey(e)
{
if (null == e)
e = window.event ;
if (e.keyCode == 13)
{
zipsearch();
}
}
function zipsearch()
{
for (i=0;i<zipArray.length;i++)
{
if (zipArray[i] == document.forms[0].zip.value)
{
document.location.href="2011/march/zone1/zone1.html";
alert("");
return true;
}
if (zip2Array[i] == document.forms[0].zip.value.toUpperCase())
{
window.location="2011/march/zone2/zone2.html"
return true;
}
alert("That Zipcode is either invalid or not in our records!")
document.forms[0].zip.focus();
return false;
}
}
</script>
</head>
<body onload="document.myform.zip.focus()">
<form method="POST" name="myform">
<input name="zip" id="zip" type="text" size="15" border="1"/>
<input type="button" class="searchbutton" value="Search" onclick="zipsearch();" border="1" />
<input type="hidden" name="hiddendata"/>
</form>