﻿

function setEnterKeyForLoginFields(usernameBoxId, passwordBoxId, loginButtonID)
{
    var usernameBox=document.getElementById(usernameBoxId);
    var passwordBox=document.getElementById(passwordBoxId);
    var loginButton=document.getElementById(loginButtonID);      

    /** fields have to exist! ****/   
    if(!(usernameBox && passwordBox && loginButton)) return;

    usernameBox.onkeydown = usernameKeyPress;
    passwordBox.onkeydown = usernameKeyPress;

    function usernameKeyPress(e)
    {
      if(!e) e = window.event;

      if(e.keyCode==13) 
      {  
         loginButton.focus();
         e.cancelBubble = true;           
         if (e.stopPropagation) e.stopPropagation();
        
        var form = document.getElementById("aspnetForm");
        form.onkeypress = nothing;
      }
    }
}

function nothing() {}  