Dear all,
I tried to forward key focus like this
username text field-> password text field -> Submit button -> and then Form is submitted. Only after focus has passed password text filed, onsubmit() is allowed to call. It worked in all browsers. But unfortunately, before filling nothing in username and password fields, mouse clicking on submit button doesnt make form submit because key focus hasn’t passed password field. So I use onClick event to allow form submit. It works in IE and doesnt conflict with former key focus style. But in other browsers, original key focus style is lost. When Enter/Return key in username field is pressed, focus doenst go to password field. Instead of it, form is submitted. Onclick event conflicts with Key event. ( sorry for my English. And thanks for Mr Pittimann. I modified your code as necessary. )
<SCRIPT LANGUAGE=”JavaScript”>
var nextfield=’Email’;
dom=((document.getElementById&&!document.all)||window.opera);
function keyDown(e)
{
k=(dom)?e.which:event.keyCode;
if(k==13)
{
if(nextfield==’done’)
{
document.login_form.flag.value = “true”;
return true;
}
else
{
document.login_form[nextfield].focus();
return false;
}
}
}
document.onkeydown=function(e){return keyDown(e)};
<body>
<form name=”login_form” action=”second.php” method=”post” onsubmit=”if (document.login_form.flag.value == ‘false’) return false”
<input name=”Email” type=”text” onFocus=”nextfield =’pwd’;” >
<input name=”pwd” type=”password” onFocus=”nextfield =’done’;”>
input type=”image” name=”done” src=”btn-submit.gif” onClick=”document.login_form.flag.value = ‘true’;”>
<input type=”hidden” name=”flag” value=”false”>
</body>