sokratees9
10-10-2003, 05:46 AM
Hi
I'm pretty new to using javascript, so hopefully this problem shouldn't be too hard for some of you out there to solve.
I've set up a very simple form with a password field and a submit button. when i type in the (correct) password and press the submit button, everything is fine, it takes me to the appropriate place, but when i type in the correct password and simply hit enter, the page just reloads. any idea how i can sort this out. heres the code that i currently have
for the edit field;
<input type="text" name="User" size="15" onKeyPress="checkEnter(event)">
and the javascript;
<script language="JavaScript">
NS4 = (document.layers) ? true : false;
function checkEnter(event)
{
var code = 0;
if (NS4)
code = event.which;
else
code = event.keyCode;
if (code==13)
document.passwd.submit();
}
</script>
any help would be great
Thanks in advance
Sok
I'm pretty new to using javascript, so hopefully this problem shouldn't be too hard for some of you out there to solve.
I've set up a very simple form with a password field and a submit button. when i type in the (correct) password and press the submit button, everything is fine, it takes me to the appropriate place, but when i type in the correct password and simply hit enter, the page just reloads. any idea how i can sort this out. heres the code that i currently have
for the edit field;
<input type="text" name="User" size="15" onKeyPress="checkEnter(event)">
and the javascript;
<script language="JavaScript">
NS4 = (document.layers) ? true : false;
function checkEnter(event)
{
var code = 0;
if (NS4)
code = event.which;
else
code = event.keyCode;
if (code==13)
document.passwd.submit();
}
</script>
any help would be great
Thanks in advance
Sok