Click to See Complete Forum and Search --> : how to associate enter to Login button? Help!


jfernandez
04-11-2006, 08:58 PM
Hi,

I'm adding the login/password fields and a button as part of my home page. The scenario would be the same as your login in the webdeveloper.com website. User just need to give login/password and then press "Enter" key and no need to click the Login button.

I wonder is that done in Javascript? I currently use

function entsub()
{
if(window.event && window.event.keyCode == 13)
{
document.forms[0].page_action.value = "login";
document.forms[0].submit();
}
else
{
return true;
}
}

but that only works for IE, not for firefox. I'm sure there's a much better way out there. Can someone give me some advice or post the code there? Really appreciate that.


Joaquin

hyperlisk
04-11-2006, 11:22 PM
[EDIT] Never mind this. I was wrong.

felgall
04-12-2006, 01:42 AM
function entsub(e)
{
var pK = e ? e.which : window.event.keyCode;
if (pK == 13)
{
document.forms[0].page_action.value = "login";
document.forms[0].submit();
}
else
{
return true;
}
}

jfernandez
04-12-2006, 08:24 PM
thanks felgall. That works for me.