HighDots Forums  

Using Enter Key in Firefox with other Javascipts also

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Using Enter Key in Firefox with other Javascipts also in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
brianhetzman@gmail.com
 
Posts: n/a

Default 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>

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.