开发者

HTML: What determines the 'move the focus to the next control when Enter is hit' behavior

A basic HTML question. Is it possible on an HTML page to declaratively achieve a behavior when pressing Enter in a textbox moves the focus to the next control? How do you achieve it and how do you turn it off? Or maybe the dynamic javascript part should be involved here?

For exaple, the following HTML in IE7 does not allow to move to the focus to the next textbox with enter:

<html>
<body>
<form>
<table>
<tr><td>
<input type="text" name="i1"/>
<td></tr>
<tr><td>
<input type="text" name="i2"/>
<td></tr>    
</table>
</form>
</body>
</html>

I have a page where I need to get rid of this 'move the focus to the next control when Enter is pressed' behavior.

@Edit: The example above turns out to be incorrect. The control the focus jumps to when I press enter on the page I want to avoid this behavior on is actually of type submit. The strange thing is that this "submit" is a part of a Telerik tree control and is not a submit button but an arrow used开发者_高级运维 to collapse and expand the tree structure. So I assume the focus jumps to the next submit control which the Browser expects to be a normal submit button which is not true in my case.

So I suppose I should look for a Telerik pecific solution here.


In most browsers, pressing Enter when focused within a form will submit the form. If you need to change this behavior so that pressing Enter moves to the next textbox you will need to use javascript.

Try this: (courtesy of javascript.internet.com)

http://javascript.internet.com/forms/tab-key-emulation.html


<input type="text" name="i1" Tabindex="[order number]"/>

I usually lookup these things on: http://start.gotapi.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜