Using Enter Key in Firefox with other Javascipts also -
12-17-2008
, 05:14 PM
Hi,
I have a form that validates against a function to direct a user to a
different webpage based on the zipcode they enter. I have this script
running properly. But in Firefox, the "enter" key does not submit the
form. Could someone please give me some direction. Below is the
script.
<SCRIPT TYPE="text/javascript">
<!--
function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
{
myfield.form.submit();
return false;
}
else
return true;
}
function zipValidate(){
val = document.zipForm.zip.value;
switch(val){
case "33701":
case "33702":
case "33703":
document.location = '33701-34698.html';
break;
case "33523":
case "33525":
case "33647":
document.location = '33510-33647.html';
break;
default:
document.location = 'invalid.html';
break;
}
}
</script>
</head>
<body onload="MM_preloadImages('images/go_over.gif')">
<form name="zipForm" id="zipForm" method="get" action="">
<input name="zip" type="text" id="zip" size="12" maxlength="5" />
<input name="zipButton" type="button" id="zipButton" value="GO"
onclick="zipValidate()" onKeyPress="return submitenter(this,event)">
</form>
</body> |