/    Sign up×
Community /Pin to ProfileBookmark

how to associate enter to Login button? Help!

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

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@hyperliskApr 12.2006 — [EDIT] Never mind this. I was wrong.
Copy linkTweet thisAlerts:
@felgallApr 12.2006 — 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;

}

}
Copy linkTweet thisAlerts:
@jfernandezauthorApr 13.2006 — thanks felgall. That works for me.
×

Success!

Help @jfernandez spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...