dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: how to associate enter to Login button? Help!

  1. #1
    Join Date
    Jan 2006
    Posts
    33

    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

  2. #2
    Join Date
    Mar 2006
    Location
    California
    Posts
    306
    [EDIT] Never mind this. I was wrong.
    Last edited by hyperlisk; 04-12-2006 at 12:45 AM.

  3. #3
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    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;
    }
    }

  4. #4
    Join Date
    Jan 2006
    Posts
    33
    thanks felgall. That works for me.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles