如何在jsp中使用keypress事件 [英] how to use keypress event in jsp
本文介绍了如何在jsp中使用keypress事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的项目中使用java,html,jsp并且我想将光标从一个文本框移动到另一个文本框中,一旦用户输入第一个值,光标应该继续到下一个字段的相应值,即我必须分配
i am using java,html,jsp in my project & i want to move the cursor from one textbox to another & as soon as the user enters the first value, the cursor should go on to next field the coresponding value which i have to assign
推荐答案
根据您的要求,我可以做出以下步骤。
From your requirement I can make out the following steps.
- 确定您何时想要专注于第二个
TextBox
的标准。
例如 - 当MaxLength
到达时,焦点将转到第二个TextBox
。
- 使用
javaScript
onkeypress事件 [ ^ ]第一个TextBox
并调用一个函数。 - 在该函数上,检查条件/条件是否满足,只需使用 HTML DOM focus()方法 [ ^ ]专注于您想要关注的
TextBox
。
- Decide the criteria when exactly you want to have the focus on the second
TextBox
.
For Example - whenMaxLength
reaches, the focus will go to secondTextBox
.
- Use the
javaScript
onkeypress Event[^] for the firstTextBox
and call one function. - On that function, check if the criteria/condition is satisfied or not and just use HTML DOM focus() Method[^] to focus on the
TextBox
you want to give focus on.
>
这篇关于如何在jsp中使用keypress事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文